Fill Rectangle with LinearGradientBrush static resource
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF" Height="300" Width="300">
<Canvas Margin="5">
<Canvas.Resources>
<LinearGradientBrush x:Key="LGB1" SpreadMethod="Reflect" StartPoint="0.5,-0.25" EndPoint="0.5,.5">
<GradientStop Color="Aqua" Offset="0.5" />
<GradientStop Color="Navy" Offset="1.0" />
</LinearGradientBrush>
</Canvas.Resources>
<Rectangle Canvas.Top="5" Canvas.Left="5" Fill="{StaticResource LGB1}" Height="180" Width="80" />
</Canvas>
</Window>
Related examples in the same category