Gets or sets a collection of application-scope resources, such as styles and brushes.
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
<object> <object.Resources> <ResourceDictionary .../> </object.Resources> </object>
The property can be used to share resources across the windows and elements of an application. Additionally, the property is included in the resource lookup path, which is traversed in the following order:
Consequently, user interface (UI) elements can bind to application-scope resources. Additionally, if resources change, the resource system ensures that element properties which are bound to those resources are automatically updated to reflect the change.
Application-scope resources provide a simple way to support a consistent theme across your application. You can easily create a theme in XAML by using the Application.Resources tag. However, if your application supports multiple themes, which may contain a large number of theme elements, it might be easier to manage them using one ResourceDictionary instance for each theme. In this way, a new theme can be applied by setting the Resources property to the appropriate ResourceDictionary.
There are two considerations to make when using . First, the dictionary key is an object, so you need to use exactly the same object instance when both setting and getting a property value (note that the key is case-sensitive when using a string). Second, the dictionary value is an object, so you will need to convert the value to the desired type when getting a property value.
is thread safe and is available from any thread.
This example illustrates how to use XAML together with application-scope resources to create a consistent visual appearance.
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml" > <Application.Resources> <SolidColorBrush x:Key="BackgroundColor" Color="Yellow"></SolidColorBrush> </Application.Resources> </Application>
The following example shows how to set an application resource in code and XAML.
The following example shows how to get an application resource in code.
Windows Phone 8.1, Windows Phone 8, 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.