These are chat archives for AvaloniaUI/Avalonia

Aug 2018
Aug 16 2018 06:06
Ill see if i can get a repro
Aug 16 2018 13:34
Hi, i've got this property in my VM: public Brush IsConnectedBrush =>
IsConnected ? new SolidColorBrush(Colors.Chartreuse) : new SolidColorBrush(Colors.IndianRed);
Which binded to Background property of some control
At start IsConnected is false, so background set to IndianRed
Then IsConnected is changed, but creation of brush with color Chartreuse throws exception like "Calling from invalid thread"
So color remains the same
I cant call it from Dispatcher thread and return value ofc
because its property
Why SolidColorBrush throws such exception?
As I see in sources, its imposible
So problem is somewhere on level higher (when value is being returned from property?)
With converter story is same
Aug 16 2018 13:46

I cant call it from Dispatcher thread and return value ofc

u can do it in property

Aug 16 2018 13:51
ofc I can, like this:
            SolidColorBrush brush = null;

            Dispatcher.UIThread.InvokeAsync(() =>
                if (IsConnected)
                    brush = new SolidColorBrush(Colors.Chartreuse);
                    brush = new SolidColorBrush(Colors.IndianRed);

            return brush;
but it will return null
Aug 16 2018 14:48
InvokeAsync do it async. Wait invokeasync result.
Steven Kirk
Aug 16 2018 15:19
@Stratocast3r i think you need to set IsConnected on the UI thread
Adam Dusty
Aug 16 2018 18:15
Is it possible to use WPF toolkits like mahapps with avalonia?
Aug 16 2018 18:32
Unfortunately not compatible
It could be ported to avlonia
Or individual controls or styles
Nicolas Musset
Aug 16 2018 21:28
@Stratocast3r @MonkAlex after my PR is merged you will be able to do return await Dispatcher.InvokeAsync(() => return new SolidColorBrush()); :smile: