<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" 
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="PresentationOptions"
  Title="Alignment Example"
  Background="White" Margin="20">
  <Page.Resources>

    <!-- This drawing is used by the DrawingBrush objects in this 
         example. -->
    <GeometryDrawing Brush="MediumBlue" x:Key="ExampleDrawing"
      PresentationOptions:Freeze="True" >
      <GeometryDrawing.Geometry>
        <GeometryGroup>
          <EllipseGeometry RadiusX="20" RadiusY="45" Center="50,50" />
          <EllipseGeometry RadiusX="45" RadiusY="20" Center="50,50" />
        </GeometryGroup>
      </GeometryDrawing.Geometry>
      <GeometryDrawing.Pen>
        <Pen Brush="Gray" Thickness="10" />
      </GeometryDrawing.Pen>
    </GeometryDrawing>
  </Page.Resources>

  <StackPanel>
    <Rectangle Margin="20"
      Width="150" Height="150"
      Stroke="Red" StrokeThickness="2"
     HorizontalAlignment="Left">
      <Rectangle.Fill>
        <DrawingBrush Drawing="{StaticResource ExampleDrawing}" 
          Stretch="None"
          AlignmentX="Left"
          AlignmentY="Top" />
      </Rectangle.Fill>
    </Rectangle>

    <Rectangle
      Width="150" Height="150"
      Stroke="Red" StrokeThickness="2"
      Margin="20" HorizontalAlignment="Left">
      <Rectangle.Fill>
        <DrawingBrush Drawing="{StaticResource ExampleDrawing}" 
          Stretch="None"
          AlignmentX="Right"
          AlignmentY="Bottom" />
      </Rectangle.Fill>
    </Rectangle>

    <Grid>
      <Rectangle HorizontalAlignment="Left"
       Width="150" Height="150"
       Stroke="Black" StrokeThickness="2"
       Margin="20">
        <Rectangle.Fill>
          <DrawingBrush Drawing="{StaticResource ExampleDrawing}" 
            Stretch="Uniform"
            Viewport="0,0,0.25,0.5"
            TileMode="Tile" 
            AlignmentX="Left"
            AlignmentY="Top" />
        </Rectangle.Fill>
      </Rectangle>
      <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" 
        Margin="20" Width="37.5" Height="75" Stroke="Red" StrokeThickness="2" />
    </Grid>

    <Grid>
      <Rectangle HorizontalAlignment="Left"
        Width="150" Height="150"
        Stroke="Black" StrokeThickness="2"
        Margin="20">
        <Rectangle.Fill>
          <DrawingBrush Drawing="{StaticResource ExampleDrawing}" 
            Stretch="Uniform"
            Viewport="0,0,0.25,0.5"
            TileMode="Tile" 
            AlignmentX="Left"
            AlignmentY="Bottom" />
        </Rectangle.Fill>
      </Rectangle>
      <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" 
  Margin="20" Width="37.5" Height="75" Stroke="Red" StrokeThickness="2" />
    </Grid>


  </StackPanel>
</Page>

