一个TreeView中有不同的DataTemplates? [英] Different DataTemplates in one TreeView?

查看:76
本文介绍了一个TreeView中有不同的DataTemplates?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在一个WPF TreeView中使用两个不同的DataTemplate?

is it possible to use two different DataTemplates in one WPF TreeView?

也许是带有黄色背景的第一个和第二个公寓和带有红色背景的干渴的公寓。

Maybe the first and second flat with yellow Background and the thirt flat with red Background.

在代码或XAML中,区别的正确位置在哪里?

Where is the right place for the distinction - in Code or in XAML?

感谢您的想法。

推荐答案

不同的模板可以通过多种方式实现...

Different templates are possible in more than one ways...


  1. >各种层次结构中的模板级别。

使用选择器的模板

一个具有设置多个背景的多个数据触发器

这篇关于一个TreeView中有不同的DataTemplates?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆