Selecting the usercontrol to the relating datatemplate in mvvm
- by msfanboy
Hello,
I have lets say a WeeklyViewUserControl.xaml and a DailyViewUserControl.xaml.
Normally I used stuff like this to switch content:
<DataTemplate DataType="{x:Type ViewModel:LessonPlannerViewModel}">
<View:LessonPlannerDailyUC/>
</DataTemplate>
This worked so far. But now I have still the WeeklyViewUC which uses 90 % of the LessonPlannerViewModel code so I want to make this additionally:
<DataTemplate DataType="{x:Type ViewModel:LessonPlannerViewModel}">
<View:LessonPlannerWeeklyUC/>
</DataTemplate>
but this can not work, because from where does the ContentControl
know that VM (LessonPlannerViewModel) should display a DailyViewUC or a WeeklyViewUC ?
<ContentControl Content="{Binding VM}" />