我该如何申请一个活力四射的风格在code运行时?我该、活力、风格、code

由网友(魚的淚只有海知道)分享简介:我需要申请一个样式code IKE这样的:TextBlock.Style = TryFindResource(myStyle的)的风格;这将动态更新时资源字典被改变(即皮肤代替在运行时)。换句话说,我需要相当于使用动态资源是这样的:< TextBlock的风格={DynamicResource myStyle的}...

我需要申请一个样式code IKE这样的:

  TextBlock.Style = TryFindResource(myStyle的)的风格;
 

这将动态更新时资源字典被改变(即皮肤代替在运行时)。换句话说,我需要相当于使用动态资源是这样的:

 < TextBlock的风格={DynamicResource myStyle的}/>
 

解决方案

尝试使用SetResourceReference.

  textBlock.SetResourceReference(TextBlock.StyleProperty,myStyle的)
 
本周短线堪忧 相对看多大盘价值风格

I need to apply a style in code ike this:

TextBlock.Style = TryFindResource("MyStyle") as Style;

that will be updated dynamically when the resource dictionary is changed (i.e. skin is replaced at runtime). In other words I need the equivalent to using a dynamic resource like this:

<TextBlock Style="{DynamicResource MyStyle}" />

解决方案

Try using SetResourceReference.

textBlock.SetResourceReference(TextBlock.StyleProperty, "MyStyle")

阅读全文

相关推荐

最新文章