Duplicate VisualBrush : DrawingImage « Windows Presentation Foundation « C# / CSharp Tutorial






<Window x:Class="Chapter05.VisualBrushExample"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="VisualBrush Example" Height="190" Width="250">
    <StackPanel Margin="5" Grid.Column="0">
      <TextBlock Text="Original button:" Margin="5" />
      <Button Name="Select" ToolTip="Select" Margin="5" Width="40" Height="40">
        <Image Width="30" Height="30">
          <Image.Source>
            <DrawingImage>
              <DrawingImage.Drawing>
                <GeometryDrawing Brush="LightGray">
                  <GeometryDrawing.Geometry>
                    <PathGeometry
                      Figures="M250,75 L 50,10 75,75 60,75 20,100 40,100,40,75Z">
                      <PathGeometry.Transform>
                        RotateTransform
                        CenterX="50"
                        CenterY="50"
                        Angle="45"/>
                      </PathGeometry.Transform>
                    </PathGeometry>
                  </GeometryDrawing.Geometry>
                  <GeometryDrawing.Pen>
                    <Pen Brush="Gray" Thickness="3" />
                  </GeometryDrawing.Pen>
                </GeometryDrawing>
              </DrawingImage.Drawing>
            </DrawingImage>
          </Image.Source>
        </Image>
      </Button>


      <TextBlock Text="Copied button:" Margin="5" />
      <Button Height="40" Width="40">
        <Button.Background>
          <VisualBrush Visual="{Binding ElementName=Select}" />
        </Button.Background>
      </Button>
    </StackPanel>

</Window>
WPF Duplicate Visual Brush








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