ResourceDictionary.MergedDictionaries 属性

定义

获取 ResourceDictionary 字典的集合,这些字典构成了合并字典中的各种资源字典。Gets a collection of the ResourceDictionary dictionaries that constitute the various resource dictionaries in the merged dictionaries.

public:
 property System::Collections::ObjectModel::Collection<System::Windows::ResourceDictionary ^> ^ MergedDictionaries { System::Collections::ObjectModel::Collection<System::Windows::ResourceDictionary ^> ^ get(); };
public System.Collections.ObjectModel.Collection<System.Windows.ResourceDictionary> MergedDictionaries { get; }
member this.MergedDictionaries : System.Collections.ObjectModel.Collection<System.Windows.ResourceDictionary>
Public ReadOnly Property MergedDictionaries As Collection(Of ResourceDictionary)

属性值

合并的字典的集合。The collection of merged dictionaries.

示例

下面的示例指定两个要合并到主 ResourceDictionaryResourceDictionary 元素。The following example specifies two ResourceDictionary elements to be merged into the primary ResourceDictionary.

<Page.Resources>
  <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="myresourcedictionary.xaml"/>
      <ResourceDictionary Source="myresourcedictionary2.xaml"/>
    </ResourceDictionary.MergedDictionaries>
  </ResourceDictionary>
</Page.Resources>

注解

通过向 MergedDictionaries引用的泛型集合添加 ResourceDictionary 来合并字典。Dictionaries are merged by adding a ResourceDictionary to the generic collection referenced by MergedDictionaries. 合并的 ResourceDictionary 没有在标记中定义的资源元素。A merged ResourceDictionary does not have resource elements defined within it in markup. 相反,合并字典是未定义任何标记子元素(或未通过代码添加的元素)的 ResourceDictionary,但使用为 Source指定的 URI。Instead, the merged dictionary is a ResourceDictionary with no markup child elements defined (or with no elements added through code), but with a URI specified for Source. Source 指定使合并字典可以来自外部源,如应用程序附带的单独的资源程序集、"松散 XAMLXAML" 或特定的本地化或全局资源程序集。The Source designation enables the merged dictionary to come from an external source, such as a separate resource assembly that ships with the application, "loose XAMLXAML", or a specific localization or global resources assembly.

不支持在指定了 SourceResourceDictionary 中指定资源元素。Specifying resource elements within a ResourceDictionary that has Source specified is not supported.

MergedDictionaries 集合中的查找行为将首先搜索最后添加的 ResourceDictionary,并在找到请求的密钥后立即停止搜索。Lookup behavior within the MergedDictionaries collection will search the last-added ResourceDictionary first, and the search stops as soon as a requested key is found. 跨合并字典的集合中的重复键是非法的。Duplicate keys across the collection of merged dictionaries are not illegal. 有关合并字典行为的详细信息,请参阅合并资源字典For more information on merged dictionary behavior, see Merged Resource Dictionaries.

XAML 属性元素用法XAML Property Element Usage

<object>  
  <object.MergedDictionaries>  
    oneOrMoreResourceDictionaries  
  </object.MergedDictionaries>  
</object>  
  

XAML 值XAML Values

oneOrMoreResourceDictionariesoneOrMoreResourceDictionaries
一个或多个 ResourceDictionary 对象元素。One or more ResourceDictionary object elements. 用于 MergedDictionariesResourceDictionary 没有集合内容,并指定远程引用完整 ResourceDictionarySource 特性。A ResourceDictionary used for MergedDictionaries does not have collection content, and specifies a Source attribute that references the complete ResourceDictionary remotely.

适用于

另请参阅