支持算法FMP =" {StaticResource的{X:TextBox类型}}"在后面的代码为风格 [英] BasedOn="{StaticResource {x:Type TextBox}}" in Code Behind for Style
问题描述
您如何可以设置以下代码后面
How can you set the following in code behind?
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
我使用的是主题中的App.xaml合并。它的伟大工程的所有控制,但是当我定义样式的东西,例如文本框
,该主题风格没有得到回升,除非我用支持算法FMP
像上面,而是得到默认的文本框
风格。
I'm using a Theme merged in App.xaml. It works great for all Controls but when I define a Style for something, e.g. TextBox
, the Theme Style doesn't get picked up unless I use BasedOn
like above, instead it gets the default TextBox
Style.
现在我创建一个 DataGridTextColumn
在后面的代码,我不能让支持算法FMP
部分为 EditingElementStyle
Now I'm creating a DataGridTextColumn
in code behind and I can't get the BasedOn
part to work for the EditingElementStyle
Style editingStyle = new Style(typeof(TextBox));
editingStyle.BasedOn = ...?;
有什么建议?此外,有没有什么办法让该主题风格,而不是默认的样式,而无需使用支持算法FMP应用?
Any suggestions? Also, is there any way to get the Theme Style instead of the default Style applied without using BasedOn?
感谢
推荐答案
试试这个:
editingStyle.BasedOn = (Style) FindResource(typeof (TextBox))
和我不知道任何方式如何可以使应用该主题风格不指定支持算法FMP
。如果有这样的方式,我想知道它太...
And I don't know any way how you can make it apply the Theme style without specifying BasedOn
. If there is such a way, I would like to know it too...
这篇关于支持算法FMP =" {StaticResource的{X:TextBox类型}}"在后面的代码为风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!