Gradient brushes within a DrawingBrush. Two overlapping gradients are layered : Brush « Windows Presentation Foundation « C# / C Sharp






Gradient brushes within a DrawingBrush. Two overlapping gradients are layered

Gradient brushes within a DrawingBrush. Two overlapping gradients are layered
      

<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 Width="50" Height="50" Grid.Row="2" Grid.Column="1">
        <Rectangle.Fill>
          <DrawingBrush Viewport="0,0,1,1" TileMode="Tile">
            <DrawingBrush.Drawing>
              <DrawingGroup>
                <GeometryDrawing>
                  <GeometryDrawing.Geometry>
                    <RectangleGeometry Rect="0,0,1,1" />
                  </GeometryDrawing.Geometry>
                  <GeometryDrawing.Brush>
                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                      <LinearGradientBrush.GradientStops>
                        <GradientStop Color="Blue" Offset="0.0" />
                        <GradientStop Color="#9966CC" Offset="0.5" />
                        <GradientStop Color="MediumBlue" Offset="1.0" />
                      </LinearGradientBrush.GradientStops>
                    </LinearGradientBrush>
                  </GeometryDrawing.Brush>
                </GeometryDrawing>
                <GeometryDrawing>
                  <GeometryDrawing.Geometry>
                    <RectangleGeometry Rect="0,0,1,1" />
                  </GeometryDrawing.Geometry>
                  <GeometryDrawing.Brush>
                    <RadialGradientBrush GradientOrigin="0.75,0.25">
                      <RadialGradientBrush.GradientStops>
                        <GradientStop Color="White" Offset="0.0" />
                        <GradientStop Color="Transparent" Offset="0.5" />
                        <GradientStop Color="Transparent" Offset="0.9" />
                        <GradientStop Color="Black" Offset="1.0" />
                      </RadialGradientBrush.GradientStops>
                    </RadialGradientBrush>
                  </GeometryDrawing.Brush>
                </GeometryDrawing>
              </DrawingGroup>
            </DrawingBrush.Drawing>
          </DrawingBrush>
        </Rectangle.Fill>
      </Rectangle>

</Window>

   
    
    
    
    
    
  








Related examples in the same category

1.Set color for SolidColorBrushSet color for SolidColorBrush
2.Paint with system brushes and colors.Paint with system brushes and colors.
3.Uses a predefined SolidColorBrush, defined by the System.Windows.Media.Brushes classUses a predefined SolidColorBrush, defined by the System.Windows.Media.Brushes class
4.OpacityMask, LinearGradientBrush, RenderTransform
5.Brush resourceBrush resource
6.Use a VisualBrush to magnify a portion of the screen.Use a VisualBrush to magnify a portion of the screen.
7.Predefined brush in Brushes ClassPredefined brush in Brushes Class
8.Solid Color Brush In Code with predefined brushSolid Color Brush In Code with predefined brush
9.Solid Color Brush In Code with SolidColorBrushSolid Color Brush In Code with SolidColorBrush
10.Solid Color Brush In Code with SolidColorBrush and RGB colorSolid Color Brush In Code with SolidColorBrush and RGB color