WPF关于Generic.xaml

时间:2015-02-23 22:22:03   收藏:0   阅读:973

如果需要用到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里创建的。

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!