WPF关于Generic.xaml

如果需要用到Themes/Generic.xaml作为默认风格资源文件,不要忘了该项目的AssemblyInfo.cs中必须要有以下这段:

[assembly: ThemeInfo(

    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located

    //(used if a resource is not found in the page, 

    // or application resource dictionaries)

    ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located

    //(used if a resource is not found in the page, 

    // app, or any theme specific resource dictionaries)

)]

否则,程序将自动取当前操作系统风格。

这段没有的原因很可能是WPF项目是从别处拷来而不是直接在vs里创建的。

你可能感兴趣的:(generic)