I find that when I change a class from
public class MarkdownEditorOptions : ObservableObject
to
public class MarkdownEditorOptions : INotifyPropertyChanged, DependencyObject
as I wanted to use dependency properties, I get the error
Default value for the 'Options' property cannot be bound to a specific thread. ...\Views\ShellView.xaml
Options is declared as a dependency property on ShellViewModel
public MarkdownEditorOptions Options
{
get { return (MarkdownEditorOptions)GetValue(OptionsProperty); }
set { SetValue(OptionsProperty, value); }
}
public static readonly DependencyProperty OptionsProperty =
DependencyProperty.Register("Options", typeof(MarkdownEditorOptions), typeof(ShellViewModel), new UIPropertyMetadata(new MarkdownEditorOptions()));
whats wrong?
See these questions
Your Dependency property is not thread safe, meaning that it doesn't inherit from System.Windows.Freezable.
Change DependencyObject to Freezable and it'll work since Freezable derives from DependencyObject.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With