【问题标题】:Keep getting error on x:DataType在 x:DataType 上不断出现错误
【发布时间】:2018-02-02 15:51:03
【问题描述】:

我一直在收到“未定义 XAML 命名空间中的属性‘DataType’。 [未定义 XAML 命名空间中的属性“DataType”][1]

<Page
   x:Class="VisitorApp.sample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:VisitorApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:data="using:VisitorApp.Common" 
mc:Ignorable="d">
    <Page.Resources>
        <DataTemplate x:Key="GuestListDataTemplate" x:DataType="data:GuestGlobal">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                <StackPanel Margin="20,20,0,0">
                <TextBlock Text="{Binding GuestName}" HorizontalAlignment="Left" FontSize="16" />
                <TextBlock Text="{x:Bind HostName}" HorizontalAlignment="Left" FontSize="10" />
                </StackPanel>
            </StackPanel>
       </DataTemplate>
    </Page.Resources>
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="0,20,20,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="100" />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="1" 
               Name="ResultTextBlock" 
               FontSize="24" 
               Foreground="Red" 
               FontWeight="Bold" 
               Margin="20,20,0,0" />
        <GridView ItemsSource ="{x:Bind Guests}" 
              ItemClick="ListView_ItemClick" 
              IsItemClickEnabled="True" 
              ItemTemplate="{StaticResource GuestListDataTemplate}">
        </GridView>
    </Grid>
</Page>

强文本

【问题讨论】:

  • 您是否尝试过简单的 DataType 而不是 x:DataType?
  • 是的,我有。它似乎拒绝那些。我只是想绑定我的班级。

标签: c# windows xaml windows-8.1


【解决方案1】:

这对我有帮助 https://msdn.microsoft.com/en-us/magazine/mt683802

感谢大家的贡献。

【讨论】:

    猜你喜欢
    • 2016-12-27
    • 1970-01-01
    • 1970-01-01
    • 2018-11-09
    • 2013-12-24
    • 2021-04-05
    • 2020-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多