How to specify two DataTemplates for single type?
I defined in XAML DataTemplate for my own type.
<DataTemplate DataType="{x:Type MyType}">
...
</DataTemplate>
Now I want to add one more template for the same type in the same scope. How would I choose then which of templates to use in concrete ItemsControl?
Background:
I have ItemsControl that displays objects of different types (derived from one base class of course) in different way depending on the item's type. So I've specified unnamed data templates for each type. Now I need to show the same data but with new tem开发者_StackOverflow社区plates (old templates supported editing, new ones - not).you would need to use DataTemplateSelector (msdn link)
you can do it by using DataTemplateSelector, Check this for details about how to use DataTemplateSelector:
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/5b4db370-095e-4233-9d89-5dd8082fd474
精彩评论