I try to bind simple synchronous command with ReactiveUI.
public ICommand ClickCommand { get; set; }
public bool IsClicked;
public MainViewModel()
{
ClickCommand = ReactiveCommand.Create(OnClick);
}
private void OnClick()
{
//just example of fast action
IsClicked = true;
}
But when I invoke it I get an error:
System.InvalidOperationException: The calling thread can not access this object, since the owner of this object is another thread
In the invocation stack i can see it is about System.Windows.Controls.Primitives.ButtonBase.UpdateCanExecute(). How can i avoid changes of ReactiveCommand.CanExecute or force it to invoke in the UI thread?