Silverlight 中的样式控件 - 全局 [英] Style controls in Silverlight - global
本文介绍了Silverlight 中的样式控件 - 全局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法为应用程序中使用的所有文本框创建全局"样式?所以我不必在每个 TextBox 上做 Template=... ?
Is there any way to create "global" styles for all TextBoxes used in application? So I don't have to do Template=... on each TextBox ?
推荐答案
是的.您需要使用隐式样式.
Yes. You need to use an implicit style.
将样式声明为正常:
<Style x:Key="MyDefaultStyle" TargetType="TextBox">
....
</Style>
然后声明:
<Style TargetType="TextBox" BasedOn="MyDefaultStyle />
重要的部分是您缺少 x:Key
声明.这将应用于应用程序中未明确设置 Style
的所有文本框.将此包含在全局资源文件中.
The important part is that you are missing the x:Key
declaration. This will get applied to all TextBoxes in your application that don't explicitly set a Style
. Include this in a global resource file.
SilverlightShow.net 上有更多信息.
There's more information on SilverlightShow.net.
这篇关于Silverlight 中的样式控件 - 全局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文