Silverlight/WPF中 动态Style 的问题

来源:互联网 发布:局域网代理上网软件 编辑:程序博客网 时间:2024/06/06 02:38
举例说明:
有App.xaml 和MainPage.xaml 两个文件
App.xaml里有个button的样式 如何用代码赋值给MainPage.xaml 里的button

如果样式是在MainPage.xaml中 我是给样式指定x:name  然后用代码直接赋值给button.Style 就行了 如果样式是在App.xaml 中 怎么弄啊...

回答:

//假设x:Name="Btn"//VB:Btn.Style = CType(Application.Current.Resources.Item("Btn"), Windows.Style)//C#(由VB自动翻译而来,如有错误,请自行修改):Btn.Style == (Windows.Style)Application.Current.Resources["Btn"];


原创粉丝点击