Reputation: 1672
I am trying to show a list of videos from YouTube using a ListBox and the ItemsSource property.
What I have right now works (Below), but now I need to format my data.
<ListBox Name="lbVideos" ItemsSource="{Binding Source={StaticResource listOfVideos}}"/>
For that i'm using a DataTemplate but the problem is that the type is 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>
The code above results in me getting the error "Type 'src:Google.YouTube.Video' was not found."
What I am asking is how do I use namespaces in a DataTemplate?
Upvotes: 3
Views: 4596
Reputation: 185489
The namespace containing your type needs to already be mapped in your xmlns
attribute, i.e.
xmlns:src="clr-namespace:YouTube_Notifier.Google.YouTube"
{x:Type src:Video}
See also the namespace mapping reference and the reference for x:Type
...
Upvotes: 9