Reputation: 2741
In a CM WPF application I have following items:
<Window> <!-- Shell Window -->
<ContentControl x:Name="MainRegion">
<ContentControl x:Name="SearchRegion">
<Window>
Views:
MainRegionView
SearchRegionView
View Models:
MainRegionViewModel //implements Conductor<Screen>
SearchRegionViewModel //implements Conductor<Screen>
I neet to switch the view of SearchRegionViewModel from MainRegionViewModel. Following code is executed inside MainRegionViewModel.
ViewModelTest test = new ViewModelTest();
//Calling the method from object reference
searchRegionViewModel.ActivateItem(test);
Problem: the view is not loaded in SearchRegionView. How can i load the view to SearchRegion?
Upvotes: 1
Views: 1344
Reputation: 1687
Your MainRegionViewModel
& SearchRegionView
need to implement Screen and your ShellViewModel
is the one that need to implement the Conductor. After that, you need to bind the ActiveItem in the XAML (ShellView.xaml).
<ContentControl x:Name="ActiveItem"></ContentControl>
Inside your ShellViewModel use Activate(YourViewModel)
.
Here is an Example
If you want to change the ActiveItem inside your MainRegionViewModel, You need to look at the EventAggregator to publish a message to your ShellViewModel to Activate
the desire ViewModel
Upvotes: 1