C# 将DataTemplate与ViewModel和View绑定。WP8
我正试图在MainPage.xaml资源中将视图模型与视图绑定在一起。就像WPF一样。 但在WP8中,结果是无法识别数据类型,我在google上也并没有找到多少解决方案C# 将DataTemplate与ViewModel和View绑定。WP8,c#,wpf,xaml,mvvm,windows-phone-8,C#,Wpf,Xaml,Mvvm,Windows Phone 8,我正试图在MainPage.xaml资源中将视图模型与视图绑定在一起。就像WPF一样。 但在WP8中,结果是无法识别数据类型,我在google上也并没有找到多少解决方案 <phone:PhoneApplicationPage.Resources> <DataTemplate x:Key="DataTemplate" DataType="{x:Type vm:ViewModel}"> <v:View></v:View>
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="DataTemplate" DataType="{x:Type vm:ViewModel}">
<v:View></v:View>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
还有别的办法吗?我想在我的主页中将视图和视图模型放在一起
谢谢大家 在这种情况下,请尝试使用DataTemplateSelector。wpsdk中没有数据类型这样的东西。如前所述,尝试DataTemplateSelector。