Your constructor expects an instance of the class
MyViewModel
. You either need to pass in an existing instance of that class, or a new instance of that class.
MyViewModel viewModel = GetTheViewModelInstanceFromSomewhere();
ExampleClass newExampleClass = new ExampleClass(viewModel);
or:
MyViewModel viewModel = new MyViewModel();
ExampleClass newExampleClass = new ExampleClass(viewModel);
If you're creating the instance from code within an instance the
ExampleClass
and you want to pass in the current viewmodel, then you'll need to cast the
DataContext
since you haven't stored it anywhere else.
MyViewModel viewModel = DataContext as MyViewModel;
ExampleClass newExampleClass = new ExampleClass(viewModel);
NB: You will not be able to use the WPF designer with this window, since it has no way to create an instance of your window class.