[英]The name "Customer does not exist in the namespace "using:...." UWP
So, im new to UWP and im trying to make some sort of an app in UWP, where i want to print a list of Customers into the window so to speak.所以,我是 UWP 的新手,我试图在 UWP 中制作某种应用程序,我想在其中将客户列表打印到窗口中。 my XAML code looks like this:
我的 XAML 代码如下所示:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="100"/>
</Grid.RowDefinitions>
<ListView ItemsSource="{x:Bind local:Customer}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="data:Customer">
<StackPanel>
<TextBlock FontSize="16" Text="{x:Bind Name}"/>
<TextBlock FontSize="10" Text="{x:Bind Address}"/>
<TextBlock FontSize="10" Text="{x:Bind PhoneNumber}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<TextBlock Grid.Row="1" Name="ResultTextBlock" FontSize="24" Foreground="Red" FontWeight="Bold" Margin="0,20,0,0"/>
</Grid>
What gives me an error is this:什么给我一个错误是这样的:
<DataTemplate x:DataType="data:Customer">
I've been trying to look up an answer that could help, using my Solution name我一直在尝试使用我的解决方案名称查找可以提供帮助的答案
using UwpNavigationTest1;
In all my files, doesnt make it go away.在我所有的文件中,并没有让它消失。 I cant really find the .VS file to remove, like a hidden file.
我真的找不到要删除的 .VS 文件,就像隐藏文件一样。 Is there any other fix to this?
有没有其他解决方法?
Kind Regards亲切的问候
Derive from official document When using {x:Bind} with data templates, you must indicate the type being bound to by setting an x:DataType value, as shown in the Examples section .源自官方文档当将 {x:Bind} 与数据模板一起使用时,您必须通过设置 x:DataType 值来指示要绑定的类型,如示例部分所示。
The name “Customer does not exist in the namespace ”using:…" UWP
名称“客户在命名空间中不存在”使用:...”UWP
If you just place Customer class under the project's root folder, please replace x:DataType="data:Customer"
with x:DataType="local:Customer"
.如果您只是将 Customer 类放在项目的根文件夹下,请将
x:DataType="data:Customer"
替换为x:DataType="local:Customer"
。 And if the Customer
class in other namespace but not current project namespace, please using the namespace in xaml like the following.如果
Customer
类在其他命名空间但不是当前项目命名空间,请使用 xaml 中的命名空间,如下所示。
<Page
x:Class="ListViewTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:data="using:ListViewTest.Model"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">
......
<DataTemplate x:Key="DemoItemTemplate" x:DataType="data:Item">
For more info please refer UWP binding depth document.有关更多信息,请参阅 UWP 绑定深度文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.