举例说明:
有App.xaml 和MainPage.xaml 两个文件
App.xaml里有个button的样式 如何用代码赋值给MainPage.xaml 里的button
有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"];