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