Hello I got a dependency property registered for my UserControl
public partial class MyControl: UserControl
public bool IsReadOnly
{
get => (bool)GetValue(IsReadOnlyProperty);
set => SetValue(IsReadOnlyProperty, value);
}
public static readonly DependencyProperty IsReadOnlyProperty
= DependencyProperty.Register(nameof(IsReadOnly), typeof(bool), typeof(SearchableInstrumentPicker),
new FrameworkPropertyMetadata(false));
I’m using ReactiveUI to observe changes to IsReadOnly and enable/disable a command
public MyControl()
{
InitializeComponent();
DispatcherScheduler uiScheduler = DispatcherScheduler.Current;
MyCommand = ReactiveCommand.Create(ShowSomeAnotherForm, this.WhenAnyValue(x => x.IsReadOnly).ObserveOnDispatcher().Select(val => !val), uiScheduler);
}
But I get thread error. Basically underlying exception is can not access object because another thread owns it. But I do specify ObserveOnDispatcher().
Tried also combinations of ObserveOn(uiScheduler).SubscribeOn(uiSchaduler)
but to no avail.
Tried to specify different combinations of SubscribeOn and ObserveOn. Also tried to channel IsReadOnly to normal property and use that one in command creation.