Using a DrawingBrush as an Opacity Mask : DrawingBrush « Windows Presentation Foundation « C# / C Sharp






Using a DrawingBrush as an Opacity Mask

Using a DrawingBrush as an Opacity Mask
 

<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">
    <Rectangle Height="150" Width="200" Stroke="Black" StrokeThickness="1">
      <Rectangle.Fill>
        <DrawingBrush>
          <DrawingBrush.Drawing>
            <GeometryDrawing>
              <GeometryDrawing.Brush>
                <RadialGradientBrush>
                  <RadialGradientBrush.GradientStops>
                    <GradientStop Offset="0" Color="Black"/>
                    <GradientStop Offset="1" Color="Transparent"/>
                  </RadialGradientBrush.GradientStops>
                </RadialGradientBrush>
              </GeometryDrawing.Brush>
              <GeometryDrawing.Geometry>
                <RectangleGeometry Rect="0.05,0.05 0.9,0.9" />
              </GeometryDrawing.Geometry>
              <GeometryDrawing.Pen>
                <Pen Thickness="0.1" Brush="Black" />
              </GeometryDrawing.Pen>
            </GeometryDrawing>
          </DrawingBrush.Drawing>
        </DrawingBrush>
      </Rectangle.Fill>
    </Rectangle>

</Window>

   
  








Related examples in the same category

1.DrawingBrush and DrawingGroupDrawingBrush and DrawingGroup
2.DrawingBrush.Transform SkewTransformDrawingBrush.Transform SkewTransform
3.DrawingBrush.RelativeTransform RotateTransformDrawingBrush.RelativeTransform RotateTransform
4.Opacity Mask from DrawingOpacity Mask from Drawing
5.A DrawingBrush paints an area with a drawingA DrawingBrush paints an area with a drawing
6.Patterns defined by the DrawingBrush expand to fill the area of the rectanglePatterns defined by the DrawingBrush expand to fill the area of the rectangle
7.Non-tiled Drawingrush examplesNon-tiled Drawingrush examples
8.Tiled DrawingBrush examplesTiled DrawingBrush examples
9.An ImageDrawing enables a DrawingBrush to contain imagesAn ImageDrawing enables a DrawingBrush to contain images