0

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?

4

1 回答 1

1

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 some ItemsControl so simply fallow this article.

于 2012-10-30T10:07:51.363 回答