Wpf 在DataTemplate数据类型中使用命名空间
我正在尝试使用ListBox和ItemsSource属性显示YouTube上的视频列表 我现在所做的工作(如下),但现在我需要格式化我的数据Wpf 在DataTemplate数据类型中使用命名空间,wpf,xaml,data-binding,namespaces,datatemplate,Wpf,Xaml,Data Binding,Namespaces,Datatemplate,我正在尝试使用ListBox和ItemsSource属性显示YouTube上的视频列表 我现在所做的工作(如下),但现在我需要格式化我的数据 <ListBox Name="lbVideos" ItemsSource="{Binding Source={StaticResource listOfVideos}}"/> 为此,我使用了一个数据模板,但问题是类型是Google.YouTube.Video <Application x:Class="YouTube_Notifie
<ListBox Name="lbVideos" ItemsSource="{Binding Source={StaticResource listOfVideos}}"/>
为此,我使用了一个数据模板,但问题是类型是Google.YouTube.Video
<Application x:Class="YouTube_Notifier.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="AppStartup"
xmlns:src="clr-namespace:YouTube_Notifier"
xmlns:System="clr-namespace:System;assembly=mscorlib">
<Application.Resources>
<DataTemplate DataType="{x:Type src:Google:YouTube:Video}">
</DataTemplate>
</Application.Resources>
</Application>
上面的代码导致我出现错误“找不到'src:Google.YouTube.Video'类型”
我要问的是如何在数据模板中使用名称空间?包含类型的名称空间需要已经映射到
xmlns
属性中,即
xmlns:src="clr-namespace:YouTube_Notifier.Google.YouTube"
另请参见和…这比我想象的要容易。谢谢!:-)
{x:Type src:Video}