A multi-platform .NET UI framework. -!-!-!-!- VOTE FOR SUPPORT IN RIDER: https://youtrack.jetbrains.com/issue/RIDER-39247 -!-!-!-!-
OmniXaml.LoadException: Error loading XAML: OmniXaml.ParseException: The type "{:DynamicResourceExtension} cannot be found"
trying to use DynamicResource like this:
<ScrollViewer MinWidth="190" Background="{DynamicResource ThemeAccentBrush}" DockPanel.Dock="Left">
var template = (DataTemplate)new AvaloniaXamlLoader().Load(xaml);
new FuncDataTemplate<MyViewModel>(x => new TextBlock
{
[!TextBlock.TextProperty] = new Binding("Foo") // Binds to MyViewModel.Foo
});
{System.InvalidOperationException: Call from invalid thread
My view's datacontext is a viewmodel like this:
loginCommand = ReactiveCommand.CreateFromTask(login);
private async Task login() {
// TODO: stuff and things
await Task.Delay(1000);
}
And the command is bound to a Button
's command;
but when the button is pressed, I get this exception:
{System.InvalidOperationException: Call from invalid thread
at Avalonia.Threading.Dispatcher.VerifyAccess()
at Avalonia.AvaloniaObject.VerifyAccess()
at Avalonia.AvaloniaObject.GetValue(AvaloniaProperty property)
at Avalonia.AvaloniaObject.GetValue[T](AvaloniaProperty`1 property)
at Avalonia.Controls.Button.get_CommandParameter()
at Avalonia.Controls.Button.CanExecuteChanged(Object sender, EventArgs e)
at ReactiveUI.ReactiveCommand.OnCanExecuteChanged()
at ReactiveUI.ReactiveCommand`2.<.ctor>b__9_5(Boolean _)
at System.Reactive.AnonymousSafeObserver`1.OnNext(T value)
at System.Reactive.Linq.ObservableImpl.RefCount`1._.OnNext(TSource value)
at System.Reactive.Subjects.FastImmediateObserver`1.EnsureActive(Int32 count)
at System.Reactive.Subjects.FastImmediateObserver`1.EnsureActive()
at System.Reactive.Subjects.ReplaySubject`1.ReplayBase.OnNext(T value)
at System.Reactive.Subjects.ReplaySubject`1.OnNext(T value)
at System.Reactive.Linq.ObservableImpl.AsObservable`1._.OnNext(TSource value)
at System.Reactive.Linq.ObservableImpl.DistinctUntilChanged`2._.OnNext(TSource value)
at System.Reactive.Linq.ObservableImpl.CombineLatest`3._.S.OnNext(TSecond value)
at System.Reactive.Linq.ObservableImpl.RefCount`1._.OnNext(TSource value)
at System.Reactive.Subjects.FastImmediateObserver`1.EnsureActive(Int32 count)
at System.Reactive.Subjects.FastImmediateObserver`1.EnsureActive()
at System.Reactive.Subjects.ReplaySubject`1.ReplayBase.OnNext(T value)
at System.Reactive.Subjects.ReplaySubject`1.OnNext(T value)
at System.Reactive.Linq.ObservableImpl.AsObservable`1._.OnNext(TSource value)
at System.Reactive.Linq.ObservableImpl.DistinctUntilChanged`2._.OnNext(TSource value)
at System.Reactive.Linq.ObservableImpl.Concat`1._.OnNext(TSource value)
at System.Reactive.Linq.ObservableImpl.Select`2._.OnNext(TSource value)
at System.Reactive.SafeObserver`1.OnNext(TSource value)
at System.Reactive.ScheduledObserver`1.Dispatch(ICancelable cancel)
at System.Reactive.Concurrency.Scheduler.<>c.<ScheduleLongRunning>b__72_0(Action`1 a, ICancelable c)
at System.Reactive.Concurrency.DefaultScheduler.LongRunning.<>c__DisplayClass1_0`1.<ScheduleLongRunning>b__0(Object arg)
at System.Reactive.Concurrency.ConcurrencyAbstractionLayerImpl.<>c__DisplayClass7_0.<StartThread>b__0()
at System.Threading.Thread.ThreadMain_ThreadStart()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()}
System.Threading.ThreadHelper.ThreadStart()
CanExecute
state is being changed from a b/g thread
ICommand
implementations?
CreateFromTask
just doesn't work with avalonia?
ReactiveCommand.CreateFromTask(Login, outputScheduler: AvaloniaScheduler.Instance)
looks like it might fix it
UseReactiveUI
on your AppBuilder
to configure rxui
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.LogToDebug()
.UsePlatformDetect()
.UseReactiveUI();
UseReactiveUI
, that solves the threading problem, but not this one