<Rectangle Margin="0,0,0,0"> <Rectangle.Fill> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Color="DarkBlue" Offset="0.3" /> <GradientStop Color="SlateBlue" Offset="0.7" /> </LinearGradientBrush> </Rectangle.Fill> </Rectangle>
 
<Grid.Resources>
   <Style x:Key="myRectangleStyle" TargetType="Rectangle">
       <Setter Property="Margin" Value="0,0,0,0" />
       <Setter Property="Fill">
           <Setter.Value>
             <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
               <GradientStop Color="DarkBlue" Offset="0.3" />
               <GradientStop Color="SlateBlue" Offset="0.7" />
             </LinearGradientBrush>
           </Setter.Value>
       </Setter>
  </Style>
</Grid.Resources>
<Rectangle Style="{StaticResource myRectangleStyle} />