如何获得standardstyles.xaml中样式的运行时访问权限? [英] How do I get runtime access to the styles in standardstyles.xaml?

查看:84
本文介绍了如何获得standardstyles.xaml中样式的运行时访问权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应该是一个容易的人,但我还没有想出来。在运行时,我希望能够将标准样式.xaml中的某些按钮样式应用到某些按钮。我不确定如何从我的页面访问该集合。是挂起App对象
(我在那里看不到它),如果是这样,我怎么能访问App对象呢?我只是不确定我是否理解standardstyles.xaml中的ResourceDictionary最终成为资源字典。

解决方案

你的预感是正确的你想要的使用App对象访问标准样式。 您可以通过访问App.Current.Resources来实现。 例如:

样式titleTextStyle =(样式)App.Current.Resources [" TitleTextStyle"]; 




Ought to be an easy one but I haven't figured it out yet. At runtime, I wish to be able to apply certain button styles from standardstyles.xaml to some buttons. I'm not sure how to get access to that collection from my page. Is it hanging off the App object (I can't see it there), and if so, how am I supposed to get access to the App object anyway? I'm just not sure I understand where the ResourceDictionary in standardstyles.xaml ends up being a resource dictionary for.

解决方案

Your hunch is correct that you want to use the App object to access the standard styles.  You can do that by accessing App.Current.Resources.  For instance:

Style titleTextStyle = (Style)App.Current.Resources["TitleTextStyle"];



这篇关于如何获得standardstyles.xaml中样式的运行时访问权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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