Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Silverlight 2中的不可变样式_Silverlight_Xaml_Coding Style - Fatal编程技术网

Silverlight 2中的不可变样式

Silverlight 2中的不可变样式,silverlight,xaml,coding-style,Silverlight,Xaml,Coding Style,在Silverlight 2中,有人找到了一个好的模式来绕过不可变的样式吗我的意思是,是否有人有一种解决方法,可以解决在设置元素后无法以编程方式切换元素样式的问题,即,这里的第二行将引发灾难性的失败异常: this.TestButton.Style=(Style)Application.Current.Resources[“Fred”] this.TestButton.Style=(Style)Application.Current.Resources[“Barney”] 我不知道这是否有帮助,

在Silverlight 2中,有人找到了一个好的模式来绕过不可变的样式吗

我的意思是,是否有人有一种解决方法,可以解决在设置元素后无法以编程方式切换元素样式的问题,即,这里的第二行将引发灾难性的失败异常:

this.TestButton.Style=(Style)Application.Current.Resources[“Fred”]

this.TestButton.Style=(Style)Application.Current.Resources[“Barney”]

我不知道这是否有帮助,但我相信您可以在运行时根据需要多次更改控件的模板。也许这是一个潜在的解决办法。

这是不可能的。我见过的最好的解决方法是微软的Nikhil Kothari:


无论如何,在App.xaml中集中定义样式有一个主要缺点,即当您从其他用户控件引用这些样式时,它会破坏所有设计器支持。我没有用过它,但是Nikhil的主题引擎看起来很有前途,我有一种有趣的感觉,他的许多想法最终都会被应用到silverlight产品中。

在silverlight 3中,风格是可变的,这个问题消失了-耶

谢谢你的链接。顺便说一句-代码只是说明性的-我通常不使用名称为Fred&Barney:-)的样式