Application.Resources Property
Silverlight
Gets a collection of application-scoped resources, such as styles, templates, and brushes.
Namespace: System.Windows
Assembly: System.Windows (in System.Windows.dll)
<Application> <Application.Resources> oneOrMoreResourceElements </Application.Resources> </Application>
XAML Values
Property Value
Type: System.Windows.ResourceDictionaryA ResourceDictionary object that contains zero or more application-scoped resources.
The value of the Resources property contains the ResourceDictionary that is set from XAML by using the Application.Resources property element.
The following example shows a style (textBlockStyle) declared as an application-scoped resource that is shared across multiple UIs.
First, the resource is implemented in the markup for the application class, as shown here.
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="SilverlightApplication.App" Startup="App_Startup"> <Application.Resources> <Style x:Key="textBlockStyle" TargetType="TextBlock"> <Setter Property="Foreground" Value="Red" /> </Style> </Application.Resources> </Application>
The following UIs demonstrate the application-scoped textBlockStyle being shared.
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:SilverlightApplication" x:Class="SilverlightApplication.Page"> <StackPanel> <TextBlock Style="{StaticResource textBlockStyle}"> This text is red! </TextBlock> <local:AnotherPage /> </StackPanel> </UserControl>
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="SilverlightApplication.AnotherPage"> <StackPanel> <TextBlock Style="{StaticResource textBlockStyle}"> This text is red too! </TextBlock> </StackPanel> </UserControl>
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.