A DrawingBrush paints an area with a drawing : DrawingBrush « Windows Presentation Foundation « C# / C Sharp






A DrawingBrush paints an area with a drawing

A DrawingBrush paints an area with a drawing
 
<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="100" Height="100" Stroke="Black" StrokeThickness="1">
          <Rectangle.Fill>
            <DrawingBrush >
              <DrawingBrush.Drawing>
                <DrawingGroup>
                  <DrawingGroup.Children>
                    <GeometryDrawing Geometry="M0,0.1 L0.1,0 1,0.9, 0.9,1z"
                      Brush="Gray" />
                    <GeometryDrawing Geometry="M0.9,0 L1,0.1 0.1,1 0,0.9z"
                      Brush="Gray" />
                    <GeometryDrawing Geometry="M0.25,0.25 L0.5,0.125 0.75,0.25 0.5,0.5z"
                      Brush="#FFFF00" />
                    <GeometryDrawing Geometry="M0.25,0.75 L0.5,0.875 0.75,0.75 0.5,0.5z"
                      Brush="Black" />
                    <GeometryDrawing Geometry="M0.25,0.75 L0.125,0.5 0.25,0.25 0.5,0.5z"
                      Brush="#FF0000" />
                    <GeometryDrawing Geometry="M0.75,0.25 L0.875,0.5 0.75,0.75 0.5,0.5z"
                      Brush="MediumBlue" />
                  </DrawingGroup.Children>
                </DrawingGroup>
              </DrawingBrush.Drawing>
            </DrawingBrush>
          </Rectangle.Fill>
        </Rectangle>
</Window>

   
  








Related examples in the same category

1.Using a DrawingBrush as an Opacity MaskUsing a DrawingBrush as an Opacity Mask
2.DrawingBrush and DrawingGroupDrawingBrush and DrawingGroup
3.DrawingBrush.Transform SkewTransformDrawingBrush.Transform SkewTransform
4.DrawingBrush.RelativeTransform RotateTransformDrawingBrush.RelativeTransform RotateTransform
5.Opacity Mask from DrawingOpacity Mask from Drawing
6.Patterns defined by the DrawingBrush expand to fill the area of the rectanglePatterns defined by the DrawingBrush expand to fill the area of the rectangle
7.Non-tiled Drawingrush examplesNon-tiled Drawingrush examples
8.Tiled DrawingBrush examplesTiled DrawingBrush examples
9.An ImageDrawing enables a DrawingBrush to contain imagesAn ImageDrawing enables a DrawingBrush to contain images