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;
    ...
}

谢谢!

4

1 回答 1

0

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

如果您使用一些技巧从 ResourceDictionary 获取私有成员 _dictionary 然后找到控件的所有样式,则可能是可能的。

您需要对默认样式做什么?也许还有另一种选择。

于 2009-04-23T16:24:18.287 回答