Export (0) Print
Expand All

ResourceDictionary.Source Property

Gets or sets the uniform resource identifier (URI) to load resources from.

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

member Source : Uri with get, set
<object Source="Uri" .../>

Property Value

Type: System.Uri
The source location of an external resource dictionary.

Typically, Source is specified as a Pack URI, which references the location of a resource dictionary that is included as a noncompiled Resource or Content build action by your application building project. For details on the Pack URI format, see Pack URIs in WPF.

Generally, the Source property is set only for a ResourceDictionary that is specified for the MergedDictionaries property (either as a property element in XAML, or as a ResourceDictionary item of the collection in code). In this context, setting the value for Source will merge the dictionary contents found at the supplied URI into the current ResourceDictionary. Any load failures will cause an exception to be thrown.

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>

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft