Rounded Rectangle Corner radius of 5


   
     

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Microsoft.Samples.Graphics.RectangleExample"
    WindowTitle="Example">
  <Canvas>
    <TextBlock Margin="5,5,0,0">Corner radius of 5.</TextBlock>
    <Rectangle Fill="Yellow" Stroke="Blue" RadiusX="5" RadiusY="5"
               Width="100" Height="60" Margin="5"  HorizontalAlignment="Left">
    </Rectangle>

  </Canvas>
</Page>

   
    
    
    
    
     


Pulsating Rectangle


   
     

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Rectangle Name="rect"
               Canvas.Left="96" Canvas.Top="96" 
               Width="192" Height="192"
               Stroke="Black">

    </Rectangle>

    <Canvas.Triggers>
        <EventTrigger RoutedEvent="Canvas.Loaded">
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="rect"
                                     Storyboard.TargetProperty="Width"
                                     From="192" To="204" Duration="0:0:0.1"
                                     AutoReverse="True"
                                     RepeatBehavior="Forever" />

                    <DoubleAnimation Storyboard.TargetName="rect"
                                     Storyboard.TargetProperty="Height"
                                     From="192" To="204" Duration="0:0:0.1"
                                     AutoReverse="True"
                                     RepeatBehavior="Forever" />

                    <DoubleAnimation Storyboard.TargetName="rect"
                                     Storyboard.TargetProperty="(Canvas.Left)"
                                     From="96" To="90" Duration="0:0:0.1"
                                     AutoReverse="True"
                                     RepeatBehavior="Forever" />

                    <DoubleAnimation Storyboard.TargetName="rect"
                                     Storyboard.TargetProperty="(Canvas.Top)"
                                     From="96" To="90" Duration="0:0:0.1"
                                     AutoReverse="True"
                                     RepeatBehavior="Forever" />


                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Canvas.Triggers>
</Canvas>

   
    
    
    
    
     


Fill rectangle with Rectangle.Fill tag and LinearGradientBrush


   
     
<Window x:Class="WpfApplication1.ShapesWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ShapesWindow" Height="160" Width="400">
    <Canvas>

        <Rectangle Canvas.Left = "40" Canvas.Top="40" Width="40" RadiusX="10" RadiusY="10">
            <Rectangle.Fill>
                <LinearGradientBrush>
                    <GradientStop Offset="0" Color="Blue"/>
                    <GradientStop Offset=".8" Color="Yellow"/>
                </LinearGradientBrush>
            </Rectangle.Fill>
        </Rectangle>

    </Canvas>
</Window>

   
    
    
    
    
     


Two of the drawing's rectangles are painted with an ImageBrush, creating a checkered pattern of images


   
     

<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">

      <Rectangle Width="50" Height="50" Grid.Row="0" Grid.Column="1">
        <Rectangle.Fill>
          <VisualBrush Viewport="0,0,1,0.25" TileMode="Tile" Stretch="Uniform">
            <VisualBrush.Visual>
              <StackPanel Background="White">
                <TextBlock FontSize="10pt" Margin="1">Hello, World!</TextBlock>
              </StackPanel>
            </VisualBrush.Visual>
          </VisualBrush>
        </Rectangle.Fill>
      </Rectangle>


</Window>

   
    
    
    
    
     


Paints a rectangle with a grid pattern


   
     

<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
      <Rectangle Width="50" Height="50" Grid.Row="1" Grid.Column="1">
        <Rectangle.Fill>
          <DrawingBrush Viewport="0,0,10,10" ViewportUnits="Absolute" TileMode="Tile">
            <DrawingBrush.Drawing>
              <DrawingGroup>
                <GeometryDrawing Brush="White">
                  <GeometryDrawing.Geometry>
                    <RectangleGeometry Rect="0,0,1,1" />
                  </GeometryDrawing.Geometry>
                </GeometryDrawing>
                <GeometryDrawing Brush="Blue"
                  Geometry="M 0,0 L 0,1 0.1,1 0.1,0.1 1,0.1 1,0 Z" />
              </DrawingGroup>
            </DrawingBrush.Drawing>
          </DrawingBrush>
        </Rectangle.Fill>
      </Rectangle>

</Window>

   
    
    
    
    
     


Paints a rectangle with a checkered pattern.


   
     
<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
      <Rectangle Width="150" Height="150">
        <Rectangle.Fill>
          <DrawingBrush Viewport="0,0,0.25,0.25" TileMode="Tile">
            <DrawingBrush.Drawing>
              <DrawingGroup>
                <GeometryDrawing Brush="White">
                  <GeometryDrawing.Geometry>
                    <RectangleGeometry Rect="0,0,1,1" />
                  </GeometryDrawing.Geometry>
                </GeometryDrawing>
                <GeometryDrawing Brush="Black"
                  Geometry="M 0,0 L0,0.5 0.5,0.5 0.5,1 1,1 1,0.5 0.5,0.5 0.5,0" />
              </DrawingGroup>
            </DrawingBrush.Drawing>
          </DrawingBrush>
        </Rectangle.Fill>
      </Rectangle>

</Window>