Compartilhar via


ThemeDictionary Markup Extension

Provides a way for custom control authors or applications that integrate third-party controls to load theme-specific resource dictionaries to use in styling the control.

XAML Attribute Usage

<object property="{ThemeDictionary assemblyUri}" .../>

XAML Object Element Usage

<object>
  <object.property>
    <ThemeDictionary AssemblyName="assemblyUri"/>
  <object.property>
<object>

XAML Values

assemblyUri

The uniform resource identifier (URI) of the assembly that contains theme information. Typically, this is a pack URI that references an assembly in the larger package. Assembly resources and pack URIs simplify deployment issues. For more information see Pack URIs in WPF.

Comentários

Essa extensão destina-se para preencher apenas um valor de propriedade específica: um valor para ResourceDictionary.Source.

By using this extension, you can specify a single resources-only assembly that contains some styles to use only when the Windows Aero theme is applied to the user's system, other styles when Luna theme is active, and so on. By using this extension, the contents of a control-specific resource dictionary can be automatically invalidated and reloaded to be specific for another theme when required.

The assemblyUri string (AssemblyName property value) forms the basis of a naming convention that identifies which dictionary applies for a particular theme. O ProvideValue lógica para ThemeDictionary conclui a convenção gerando um uniform resource identifier (URI) que aponta para uma variante de dicionário tema específico, como contido dentro de um assembly de recurso pré-compilado. Describing this convention, or theme interactions with general control styling and page/application level styling as a concept, is not covered fully here. The basic scenario for using ThemeDictionary is to specify the Source property of a ResourceDictionary declared at the application level. Quando você fornecer um URI para o assembly por meio de um ThemeDictionary extensão em vez de uma conexão direta URI, a lógica de extensão fornecerá a lógica de invalidação aplica sempre que alterações de tema de system.

Attribute syntax is the most common syntax used with this markup extension. The string token provided after the ThemeDictionary identifier string is assigned as the AssemblyName value of the underlying ThemeDictionaryExtension extension class.

ThemeDictionary may also be used in object element syntax. In this case, specifying the value of the AssemblyName property is required.

ThemeDictionary can also be used in a verbose attribute usage that specifies the Member property as a property=value pair:

<object property="{ThemeDictionary AssemblyName=assemblyUri}" .../>

The verbose usage is often useful for extensions that have more than one settable property, or if some properties are optional. Because ThemeDictionary has only one settable property, which is required, this verbose usage is not typical.

No WPF XAML implementação do processador, a manipulação desta extensão de marcação é definida pelo ThemeDictionaryExtension classe.

ThemeDictionary is a markup extension. Markup extensions are typically implemented when there is a requirement to escape attribute values to be other than literal values or handler names, and the requirement is more global than just putting type converters on certain types or properties. Todas as extensões de marcação no XAML usar o {e} caracteres em sua sintaxe de atributo, que é a convenção pelo qual um XAML processador reconhece que a extensão de marcação deve processar o atributo. For more information, see As extensões de marcação e o WPF XAML.

Consulte também

Conceitos

Styling and Templating

Visão geral do XAML (WPF)

As extensões de marcação e o WPF XAML

Recursos, conteúdo e arquivos de dados de aplicativos WPF