Applies a DrawingBrush and DrawingGroup to draw gridlines as a background of a Grid control. : DrawingImage « Windows Presentation Foundation « C# / CSharp Tutorial






<Window x:Class="DrawingBrushGridline"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Drawing Brush - Gridline" Height="300" Width="300">

  <Grid>
    <Grid.Background>
      <DrawingBrush Viewport="0,0,50,50" ViewportUnits="Absolute"
        TileMode="Tile">
        <DrawingBrush.Drawing>
          <DrawingGroup>
            <DrawingGroup.Children>
              <GeometryDrawing Geometry="M0,0 L50,0">
                <GeometryDrawing.Pen>
                  <Pen Thickness="2"
                    Brush="LightGreen" />
                </GeometryDrawing.Pen>
              </GeometryDrawing>
              <GeometryDrawing Geometry="M0,10 L50,10">
                <GeometryDrawing.Pen>
                  <Pen Thickness="1"
                    Brush="LightGreen" />
                </GeometryDrawing.Pen>
              </GeometryDrawing>
              <GeometryDrawing Geometry="M0,20 L50,20">
                <GeometryDrawing.Pen>
                  <Pen Thickness="1"
                    Brush="LightGreen" />
                </GeometryDrawing.Pen>
              </GeometryDrawing>
              <GeometryDrawing Geometry="M0,30 L50,30">
                <GeometryDrawing.Pen>
                  <Pen Thickness="1"
                    Brush="LightGreen" />
                </GeometryDrawing.Pen>
              </GeometryDrawing>
              <GeometryDrawing Geometry="M0,40 L50,40">
                <GeometryDrawing.Pen>
                  <Pen Thickness="1"
                    Brush="LightGreen" />
                </GeometryDrawing.Pen>
              </GeometryDrawing>
              <GeometryDrawing Geometry="M0,0 L0,50">
                <GeometryDrawing.Pen>
                  <Pen Thickness="2"
                    Brush="LightGreen" />
                </GeometryDrawing.Pen>
              </GeometryDrawing>
              <GeometryDrawing Geometry="M10,0 L10,50">
                <GeometryDrawing.Pen>
                  <Pen Thickness="1"
                    Brush="LightGreen" />
                </GeometryDrawing.Pen>
              </GeometryDrawing>
              <GeometryDrawing Geometry="M20,0 L20,50">
                <GeometryDrawing.Pen>
                  <Pen Thickness="1"
                    Brush="LightGreen" />
                </GeometryDrawing.Pen>
              </GeometryDrawing>
              <GeometryDrawing Geometry="M30,0 L30,50">
                <GeometryDrawing.Pen>
                  <Pen Thickness="1"
                    Brush="LightGreen" />
                </GeometryDrawing.Pen>
              </GeometryDrawing>
              <GeometryDrawing Geometry="M40,0 L40,50">
                <GeometryDrawing.Pen>
                  <Pen Thickness="1"
                    Brush="LightGreen" />
                </GeometryDrawing.Pen>
              </GeometryDrawing>
            </DrawingGroup.Children>
          </DrawingGroup>
        </DrawingBrush.Drawing>
      </DrawingBrush>
    </Grid.Background>
  </Grid>
</Window>
WPF Applies A Drawing Brush And Drawing Group To Draw Gridlines As A Background Of A Grid Control








24.100.DrawingImage
24.100.1.Create buttons using DrawingImage and GeometryDrawingCreate buttons using DrawingImage and GeometryDrawing
24.100.2.Applies a DrawingBrush and DrawingGroup to draw gridlines as a background of a Grid control.Applies a DrawingBrush and DrawingGroup to draw gridlines as a background of a Grid control.
24.100.3.Create buttons using DrawingImage objectsCreate buttons using DrawingImage objects
24.100.4.VisualBrush and TileModeVisualBrush and TileMode
24.100.5.Duplicate VisualBrushDuplicate VisualBrush
24.100.6.DrawingBrush Opacity from 1 to 0DrawingBrush Opacity from 1 to 0