These are chat archives for AvaloniaUI/Avalonia

7th
Feb 2018
Nihal Talur
@0xFireball
Feb 07 2018 02:11
hi, how can i extend the textbox control?
Nihal Talur
@0xFireball
Feb 07 2018 02:20
i tried creating a custom control extending TextBox, but it becomes invisible?
<TextBox
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

</TextBox>
this makes the control invisible
emmauss
@emmauss
Feb 07 2018 09:17
hello, I am new to avalonia and I want to use the nightly builds. They target .net core 2.0, but the current avalonia vs extension only supports 1.1, so I can not upgrade the included one to the prerelease. Any way to actually start using the nightly builds
Steven Kirk
@grokys
Feb 07 2018 11:32
@0xFireball could you point me to your code so I can understand what you're trying to do?
@emmauss what are you targetting at the moment? can you not just change your <TargetFramework> to target netcoreapp2.0?
danwalmsley
@danwalmsley
Feb 07 2018 12:22
@jkoritzinsky you around, I'm having problems with sharpgen tools
Chris Pie
@kpietraszko
Feb 07 2018 13:56
Am I blind, or is the FixMe button missing when designer is set to verical split?
MonkAlex
@MonkAlex
Feb 07 2018 15:08
@RexTremendae i use simple Show on windows, then its work. See #857
emmauss
@emmauss
Feb 07 2018 17:05
@grokys I changed th target framework to 2.0, deleted the obj folder, cleaned the project and reinstalled the latest avalonia and avalonia.desktop packages, it now works.
though it would be nice if the toolbox contained all available widgets. do you have any documentation on all current widget?
Jeremy Koritzinsky
@jkoritzinsky
Feb 07 2018 17:56
@grokys Can you take another pass at #1277 when you have a chance?
Steven Kirk
@grokys
Feb 07 2018 17:58
yeah, sorry i've not had a lot of time for avalonia in the last week or so
@emmauss sorry, no our documentation is virtually non-existent at the moment, it's something we really need to work on after we've got this beta out
it doesn't have all our controls in there but it has most of the important ones I think
Per Westerlund
@RexTremendae
Feb 07 2018 18:19
@MonkAlex I tried the example on GitHub you referred to, copied the exact main method to my simple test project (containing just one main window with a button and a label, no magic). It still doesn't work for me, I'm just getting a black, empty window. :(
Is your SimpleDialog doing something special to make it work?
Nihal Talur
@0xFireball
Feb 07 2018 18:24
hey @grokys I'm trying to embed a custom control like this:
<mirrorEdit:MirrorEditor />
Steven Kirk
@grokys
Feb 07 2018 18:24
in a TextBox?
Nihal Talur
@0xFireball
Feb 07 2018 18:24
I've defined the custom control as a xaml with a xaml.cs
<TextBox x:Class="MirrorEditor"
         xmlns="https://github.com/avaloniaui"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</TextBox>
and
public partial class MirrorEditor : TextBox {
yes, i'm trying to extend a textbox
but when I do this, even without the x:Class, the textbox becomes invisible
Steven Kirk
@grokys
Feb 07 2018 18:25
ok, making a xaml file for a TextBox like that doesn't make much sense. a TextBox isn't a something you can put content in
instead you need to make a control template for your control
as TextBox is a templated control
Nihal Talur
@0xFireball
Feb 07 2018 18:26
how would I do that? is there an example I can look at?
Nihal Talur
@0xFireball
Feb 07 2018 18:27
essentially my goal is to get some basic regex-based highlighting, and I saw the Spans in the textbox can do custom colorizer
Steven Kirk
@grokys
Feb 07 2018 18:29
i'm not sure you can do that by overriding TextBox tbh... the text in a TextBox is drawn by the <TextPresenter>
MonkAlex
@MonkAlex
Feb 07 2018 18:29
@RexTremendae nope, its simple window.
Nihal Talur
@0xFireball
Feb 07 2018 18:29
is there a way I can switch out that TextPresenter for a custom overrided version of my own? perhaps without making a sub-textbox?
yeah i think you could do that
start by deriving from TextPresenter and override the Render method
then you'll need to re-template TextBox to use your own TextPresenter class
you could do that by using a say mirror class on your textbox: <TextBox Classes="mirror"> and then copying the TextBox default template and changing the selector to match that class
so change this line https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Default/TextBox.xaml#L2 to read <Style Selector="TextBox.mirror">
you then need to put that template in your App.xaml or something
if that makes sense?
Steven Kirk
@grokys
Feb 07 2018 18:37
@0xFireball you might find it easier just to use AvaloniaEdit though: https://github.com/AvaloniaUI/AvaloniaEdit
Nihal Talur
@0xFireball
Feb 07 2018 19:20
I tried AvaloniaEdit but i got some errors for now that seemed like more trouble than I want to take for now, I want to keep it simple for now. I'll try the styled template way
thanks for the help
Nihal Talur
@0xFireball
Feb 07 2018 19:49
yes, I was able to successfully override it
by the way, there's a weird behavior with pressing Enter on acceptsreturn textboxes
when you press enter it moves the cursor a bit to the right of the same line
only when you type new text does it jump to the next line