I am building a WPF application using MVVM Light and having problems tying up my Views to my View Model. I have a view model in which I am passing in an Interface of IDataContext, which is basically passing in a datacontext.Then I have an View which I have inserted the following statement on top
DataContext="{Binding MyViewModel, Source={StaticResource Locator}}"
In my ViewModelLocator I have added the following lines :
IoC.Register<IDataContext, MyDataContext>();
and
IoC.Register<MyViewModel>();
And after putting a break point in the constructor of the ‘MyViewModel’, the breakpoint gets hit. Is there something I am missing, please help???
Did you define a public getter for your viewModel in ViewModelLocator class as shown below?
and then use the “MainViewModel” in the view binding as shown below
What kind of behavior you see? Empty view window with no datacontext set? OR exception when displaying your view?