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






Create buttons using DrawingImage and GeometryDrawing

Create buttons using DrawingImage and GeometryDrawing
 

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

   
  








Related examples in the same category

1.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.
2.Create buttons using DrawingImage objectsCreate buttons using DrawingImage objects
3.VisualBrush and TileMode
4.Duplicate VisualBrush
5.DrawingBrush Opacity from 1 to 0DrawingBrush Opacity from 1 to 0