WPF MVVM ViewModel constructor designmode
If you want to set the DataContext
in XAML, you can use this at the top of your ViewModel
ctor:
if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
return;
What you could try is just setting the DataContext
in the code behind and see if that resolves the issue. It is pretty much the exact same thing, but maybe your IDE is just playing up.
DataContext = new MainViewModel();