WPF - Display single entity with a data template

那年仲夏 提交于 2019-12-18 14:16:11

问题


I Have a data template that i use in items control, i wanna know if its possible some how to use it(the template) on single item display without the items control?

if not whats the best way to do it...?


回答1:


You can probably do something like this

**<DataTemplate x:Key="MyTemplate" DataType="{x:Type MyType}">**
    ...
**</DataTemplate>**
...
<ContentControl ContentTemplate="{StaticResource MyTemplate}" /> <!-- Single instance use -->
<ItemsControl ItemTemplate="{StaticResource MyTemplate}" /> <!-- Multiple instance use -->


来源:https://stackoverflow.com/questions/755167/wpf-display-single-entity-with-a-data-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!