Windows Phone 8.1 App dont see DataType property in DataTemplate

陌路散爱 提交于 2019-12-04 02:50:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!