Create buttons using DrawingImage and GeometryDrawing : DrawingImage « Windows Presentation Foundation « C# / CSharp Tutorial






<Window x:Class="Chapter05.DrawingImageExample"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="DrawingImage Example" Height="130" Width="320">
    <Button Name="DrawRectangle" Grid.Column="1"
      ToolTip="Draw Rectangle" Margin="5">
      <Image Width="80" Height="80">
        <Image.Source>
          <DrawingImage>
            <DrawingImage.Drawing>
              <GeometryDrawing Brush="LightGray">
                <GeometryDrawing.Geometry>
                  <RectangleGeometry Rect="0,20,100,60" />
                </GeometryDrawing.Geometry>
                <GeometryDrawing.Pen>
                  <Pen Brush="Gray" Thickness="3" />
                </GeometryDrawing.Pen>
              </GeometryDrawing>
            </DrawingImage.Drawing>
          </DrawingImage>
        </Image.Source>
      </Image>
    </Button>

</Window>
WPF Create Buttons Using Drawing Image And Geometry Drawing








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