In my MainWindow
I have this:
<Window.DataContext>
<viewModel:ActiveRecord />
</Window.DataContext>
In my UserControl
I have this:
<UserControl.DataContext>
<search:CustomerSearch />
</UserControl.DataContext>
before I added this 'local' binding i would reference the 'modular' binding in my UserControl
like this:
var vm = this.DataContext as ViewModel.ActiveRecord;
but because I want to reference 2 different bindings, it appears to not work any more. What I mean by that is that I populate the ActiveRecord
with values but when I navigate to another form these values are null.
What I think I need to do is access the Mainwindow's
DataContext
like this:
var vm = MainWindow.DataContext as ViewModel.ActiveRecord;
But of course DataContext
is not a property of MainWindow
How can I do this?