Managing XAML Resources
<UserControl x:Class='SilverlightApplication3.MainPage'
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
xmlns:d='http://schemas.microsoft.com/expression/blend/2008'
xmlns:mc='http://schemas.openxmlformats.org/markup-compatibility/2006'
mc:Ignorable='d'
d:DesignWidth='640'
d:DesignHeight='480'>
<UserControl.Resources>
<Color x:Key="Pumpkin">#FFD5901F</Color>
<Color x:Key="Lime">#FF75E564</Color>
<LinearGradientBrush x:Key="PumpkinLimeBrush" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="{StaticResource Lime}"/>
<GradientStop Color="{StaticResource Pumpkin}" Offset="1"/>
</LinearGradientBrush>
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Grid.Row="0" Background="{StaticResource PumpkinLimeBrush}" Margin="2,2,2,2">
</StackPanel>
<StackPanel Grid.Column="0" Grid.Row="1" Margin="2,2,2,2">
<StackPanel.Resources>
<LinearGradientBrush x:Key="FallBrush" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF000000"/>
<GradientStop Color="#FFFFA500" Offset="1"/>
</LinearGradientBrush>
</StackPanel.Resources>
<Rectangle Margin="2,2,2,2" Stroke="#FF000000" Fill="{StaticResource FallBrush}" Height="193"/>
</StackPanel>
</Grid>
</UserControl>
Related examples in the same category