引用 Silverlight 中控件的默认样式

发布于 2024-07-17 22:28:44 字数 489 浏览 5 评论 0原文

如何引用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩发小公举 2024-07-24 22:28:44

据我所知你无法获得默认样式。

如果您使用一些技巧从 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文