c# - ThemeInfo 属性有什么用?

标签 c# wpf xaml themes assemblyinfo

每当我创建一个新的 WPF 应用程序或 WPF 用户控件库时,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)
)]

ThemeInfo 属性有什么用?如果我删除它会破坏任何东西吗?

最佳答案

ThemeInfo 属性指定自动主题化机制应在何处查找主题词典和通用词典。每个选项都可以设置为以下值之一:

  • 无(默认):不查找资源字典。
  • SourceAssembly:字典是当前程序集。
  • ExternalAssembly:字典在不同的程序集中,必须命名 <AssemblyName>.<ThemeName>.dll , 其中<AssemblyName>是当前程序集的 姓名。

如果主题字典为在外部程序集中定义的控件指定样式,例如,WPF 控件,如 System.Windows.Controls.ProgressBarSystem.Windows.Button , 那么你必须使用 ThemeDictionaryExtension将应用程序指定为主题词典的来源。

关于c# - ThemeInfo 属性有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1163013/

相关文章:

c# - 在 C# 中对分组结果进行排序

c# - 如何确定 Azure StorageV2(具有分层命名空间的数据湖存储)BlobItem 是否为虚拟目录

c# - 学习 Windows 窗体与 Windows Presentation Foundation

c# - WPF 的 C# 代码中的 XPath

xaml - 实现多选项目列表

c# - RemoteCertificateChainErrors - 空 ChainElementStatus C#

c# - 我应该如何将以下 C# 语句转换为 vb.net?

wpf - 带有 MEF 2 的 WPF MvvM 中的插件

c# - 将 WPF 元素本身绑定(bind)到 View 模型对象

wpf - 在应用程序中分解大型XAML文件的最简单方法是什么?