本文介绍了根据类型使用正确的模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的
我有下面的xaml代码snipet:
I have the follwoing xaml code snipet:
I will try something else and if could not find will try to build a small demo to reproduce
by the way do you thing that in folowing snipet a trigger can be use to test the type of an Item and then based on that type set the property ItemTemplate to correct one ?
<Style TargetType="{x:Type s:LibraryStack}">
<Setter Property="ItemTemplate" Value="{StaticResource LibraryItemTemplate}"/>
<Setter Property="ItemContainerStyle" Value="{StaticResource StackItemContainerStyle}"/>
</Style>
推荐答案
我认为ItemTemplateSelector是您要寻找的东西.借助ItemTemplateSelector,我们可以根据数据属性和数据类型设置不同的ItemTempalte.
I thinks ItemTemplateSelector is what are you looking for. With ItemTemplateSelector we can set different ItemTempalte based on data property also data type.
Please refer to . http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.itemtemplateselector.aspx
希望这会有所帮助
这篇关于根据类型使用正确的模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!