Selecting the usercontrol to the relating datatemplate in mvvm
Posted
by msfanboy
on Stack Overflow
See other posts from Stack Overflow
or by msfanboy
Published on 2010-03-14T21:41:22Z
Indexed on
2010/03/14
21:45 UTC
Read the original article
Hit count: 218
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}" />
© Stack Overflow or respective owner