引用 Silverlight 中控件的默认样式
如何引用 generic.xaml 中出现的默认样式?
我正在尝试创建一个静态类,该类返回自定义控件的已知样式。 我知道如何提取 App.xaml 中存在的样式,但我不确定如何获取通用样式。
public static class VehicleTypes
{
public static readonly Style SportsCar = /*???Default style for VehicleIcon from generic.xaml*/;
public static readonly Style Sedan = Application.Current.Resources["SedanStyle"] as Style;
public static readonly Style Jeep = Application.Current.Resources["JeepStyle"] as Style;
...
}
谢谢!
How do I reference the default style that appears in generic.xaml?
I am trying to create a static class that returns known styles for a custom control. I know how to pull the styles that exist in App.xaml, but I'm not sure how to grab the generic one.
public static class VehicleTypes
{
public static readonly Style SportsCar = /*???Default style for VehicleIcon from generic.xaml*/;
public static readonly Style Sedan = Application.Current.Resources["SedanStyle"] as Style;
public static readonly Style Jeep = Application.Current.Resources["JeepStyle"] as Style;
...
}
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知你无法获得默认样式。
如果您使用一些技巧从 ResourceDictionary 获取私有成员 _dictionary,然后找到控件的所有样式,则可能是有可能的。
您需要对默认样式做什么? 也许还有另一种选择。
As far as I can tell you can't get the default style.
It may be possible if you use a bit of trickery to get the private member _dictionary from the ResourceDictionary and then find all the styles for a control.
What do you need to do with the default style? maybe there is another option.