支持算法FMP =" {StaticResource的{X:TextBox类型}}"在后面的代码为风格 [英] BasedOn="{StaticResource {x:Type TextBox}}" in Code Behind for Style

查看:265
本文介绍了支持算法FMP =" {StaticResource的{X:TextBox类型}}"在后面的代码为风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何可以设置以下代码后面

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 =&QUOT; {StaticResource的{X:TextBox类型}}&QUOT;在后面的代码为风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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