WPF中的数据模板和控件模板 [英] Datatemplates and Controltemplates in WPF
本文介绍了WPF中的数据模板和控件模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨..
我们可以为单个控件(例如文本框,列表框等)实现数据模板和控件模板,以自定义视图并为WPF中的特定控件实现数据触发器吗!
如果是,请举个例子告诉我..
谢谢.
Sekhar.
解决方案
为控件实现数据模板和控件模板都没有道理.
您使用ControlTemplate设置从控件 [ ^ ],方法是: 模板属性 [ WPF教程-样式,触发器和放大器;动画 [ ^ ]
Hi..
Can we implement both Datatemplates and controltemplates for a single control(say..Textbox, listbox etc..) for customizing both view and implementing datatriggers for a particular control in WPF..!!!!
If yes, please let me know with an example..
Thanks.
Sekhar.
解决方案
Implement both Datatemplates and controltemplates for a control doesn''t make sense.
You use ControlTemplate to style for a type derived from Control[^] by setting the Template property[^] to that ControlTemplate.
You use DataTemplate to style items in a ListBox, ComboBox, ect.
Both a ControlTemplate and DataTemplate allow you to use Triggers.
I suggest you read this article; WPF Tutorial - Styles, Triggers & Animation[^]
这篇关于WPF中的数据模板和控件模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文