我正在尝试使用ListBox和ItemsSource属性从YouTube显示视频列表。我现在拥有的代码可以工作(如下),但现在我需要格式化我的数据。
<ListBox Name="lbVideos" ItemsSource="{Binding Source={StaticResource listOfVideos}}"/>
为此我使用了DataTemplate,但问题在于类型是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>
上面的代码导致我收到错误信息:"Type 'src:Google.YouTube.Video' was not found."
我的问题是如何在DataTemplate中使用命名空间?