问题
I created new Windows Phone 8.1 project and when I try to set DataType , vs2013 give me in editor error: The property 'DataType' was not found in type 'DataTemplate'
. In WPF application I dont have this problem. How to fix it?
This is my MainPage.xml:
<Page
x:Class="App6.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App6"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<DataTemplate DataType="{x:Type local:Employee}">
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</Page.Resources>
<Grid>
</Grid>
</Page>
回答1:
DataType is not supported in WinRT XAML - see DataTemplate Class. You can also find this information here at this post.
Maybe DataTemplateSelector will help you, here is some help: one, two, three.
回答2:
DataType is not supported in WinRT XAML (Universal app), Windows Phone 8
To use different template for each type you have to DataTemplateSelector
来源:https://stackoverflow.com/questions/29041212/windows-phone-8-1-app-dont-see-datatype-property-in-datatemplate