WPF:按钮模板与 ContentTemplate
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4154775/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WPF: Button Template vs ContentTemplate
提问by Jiew Meng
Can I say that usually, in WPF, properties Template
contains ContentTemplate
? Or else, whats the difference?
我可以说通常在 WPF 中,属性Template
包含ContentTemplate
? 或者,有什么区别?
回答by Ben Gribaudo
Templatedefines the appearance of the control. ContentTemplatespecifies how the content contained in/displayed by a ContentControlis to be displayed.
模板定义了控件的外观。ContentTemplate指定如何显示ContentControl 中包含/显示的内容。
Here's a Social.MSDN threadcontaining an example that shows the difference between the two.
这是一个 Social.MSDN线程,其中包含一个示例,显示了两者之间的区别。
Hope this helps,
Ben
希望这会有所帮助,
本
回答by u778650
Template's value type is controlTemplate, which defines how control should looks like.
Template 的值类型是 controlTemplate,它定义了控件的外观。
ContentTemplate's value type is dataTemplate, which define the how data should looks like. The similar property is ItemTemplate and CellTemplate.
ContentTemplate 的值类型是 dataTemplate,它定义了数据应该是什么样子。类似的属性是 ItemTemplate 和 CellTemplate。