I have this data structure:
Post {
attachments { },
postText
}
To display this, i am using ListView
<ListView ItemsSource="{Binding Posts}"
ItemTemplate="{StaticResource PostTemplate}"
Width="Auto"
Height="Auto" />
The problem is, when i am trying to display a list of attachments inside each post.
Every attachment is simply typed link for some typed content (video/audio/image)
Attachment {
type: video,
url: urlToVideo
}
How can i display context-based template for rendering all kind of this content in attachment?
As a wpf developer my first answer was to use triggers but according to this article this is not an option for windows-8 app. But as you can see there is a way to do that using
DataTemplateSelector. I assume that you have created one template for one attachment type and you display attachments as someItemsControlso simply fallow this article.