DrawingGroup and GeometryGroup : DrawingGroup « Windows Presentation Foundation « C# / CSharp Tutorial






<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">

    <Window.Resources>
    <DrawingGroup x:Key="myDrawing" >
      <GeometryDrawing>
        <GeometryDrawing.Geometry>
          <GeometryGroup>
            <LineGeometry StartPoint="0,0" EndPoint="1,1" />
            <LineGeometry StartPoint="0,1" EndPoint="1,0" />
          </GeometryGroup>
        </GeometryDrawing.Geometry>
        <GeometryDrawing.Pen>
          <Pen Thickness="0.2" Brush="#3366FF" />
        </GeometryDrawing.Pen>
      </GeometryDrawing>
      <GeometryDrawing Brush="Red"
       Geometry="M 0.4,0.4 L 0.5,0.2 0.6,0.4 0.5,0.5" />
    </DrawingGroup>
    </Window.Resources>
    <Rectangle Width="175" Height="90" Stroke="Black">
      <Rectangle.Fill>
        <DrawingBrush Drawing="{StaticResource myDrawing}" Viewport="0,0,0.5,0.5" TileMode="Tile">
          <DrawingBrush.RelativeTransform>
            <RotateTransform CenterX="0.5" CenterY="0.5" Angle="45" />
          </DrawingBrush.RelativeTransform>
        </DrawingBrush>
      </Rectangle.Fill>
    </Rectangle>

</Window>
WPF Drawing Group And Geometry Group








24.99.DrawingGroup
24.99.1.DrawingGroup and GeometryGroupDrawingGroup and GeometryGroup
24.99.2.Draw text to the background of a control by accessing the control's DrawingContext.Draw text to the background of a control by accessing the control's DrawingContext.