Diagonal linear gradient multiple colors 2

image_pdfimage_print


   
  

<Window x:Class="WpfApplication1.LinearGradientBrushExample"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="LinearGradientBrush" Height="375" Width="300">
    <StackPanel Grid.Column="1" Grid.Row="2">
      <TextBlock Margin="5,10,5,0" Text="Diagonal linear gradient" />
      <TextBlock Margin="5,0,5,5" Text="- multiple colors" />
      <Rectangle Width="100" Height="75" Stroke="Blue">
        <Rectangle.Fill>
          <LinearGradientBrush StartPoint="0,0"
            EndPoint="1,1">
            <GradientStop Color="Red" Offset="0.2" />
            <GradientStop Color="Yellow" Offset="0.3" />
            <GradientStop Color="Coral" Offset="0.4" />
            <GradientStop Color="Blue" Offset="0.5" />
            <GradientStop Color="White" Offset="0.6" />
            <GradientStop Color="Green" Offset="0.7" />
            <GradientStop Color="Purple" Offset="0.8" />
          </LinearGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
    </StackPanel>
</Window>

   
    
     


Diagonal linear gradient with 0.5 Offset for White

image_pdfimage_print


   
  

<Window x:Class="WpfApplication1.LinearGradientBrushExample"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="LinearGradientBrush" Height="375" Width="300">
    <StackPanel>
      <TextBlock Margin="5,10,5,0"
        Text="Diagonal linear gradient" />
      <TextBlock Margin="5,0,5,5"
        Text="- with 0.5 Offset for White" />
      <Rectangle Width="100" Height="75" Stroke="Blue">
        <Rectangle.Fill>
          <LinearGradientBrush StartPoint="0,0"
            EndPoint="1,1">
            <GradientStop Color="Green" Offset="0" />
            <GradientStop Color="White" Offset="0.5" />
          </LinearGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
    </StackPanel>
</Window>

   
    
     


Horizontal linear gradient

image_pdfimage_print


   
  

<Window x:Class="WpfApplication1.LinearGradientBrushExample"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="LinearGradientBrush" Height="375" Width="300">
    <StackPanel Grid.Column="1" Grid.Row="0">
      <TextBlock Margin="5" Text="Horizontal linear gradient:" />
      <Rectangle Width="100" Height="75" Stroke="Blue">
        <Rectangle.Fill>
          <LinearGradientBrush StartPoint="0,0"
            EndPoint="0,1">
            <GradientStop Color="Red" Offset="0" />
            <GradientStop Color="White" Offset="1" />
          </LinearGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
    </StackPanel>
</Window>

   
    
     


Vertical linear gradient

image_pdfimage_print


   
  

<Window x:Class="WpfApplication1.LinearGradientBrushExample"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="LinearGradientBrush" Height="375" Width="300">
    <StackPanel>
      <TextBlock Margin="5" Text="Vertical linear gradient:" />
      <Rectangle Width="100" Height="75" Stroke="Blue">
        <Rectangle.Fill>
          <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
            <GradientStop Color="Blue" Offset="0" />
            <GradientStop Color="Yellow" Offset="1" />
          </LinearGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
    </StackPanel>
</Window>

   
    
     


LinearGradientBrush SpreadMethod

image_pdfimage_print


   
  

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

    <Canvas Width="150" Height="75" Margin="0,0,0,10">
      <Rectangle Width="150" Height="75" Stroke="Black">
        <Rectangle.Fill>
          <LinearGradientBrush StartPoint="0.3,0.5" EndPoint="0.7,0.5" SpreadMethod="Pad">
            <GradientStop Color="White" Offset="0" />
            <GradientStop Color="#333333" Offset="1" />
          </LinearGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
      <Line X1="45" Y1="40" X2="105" Y2="40"/>
    </Canvas>

</Window>

   
    
     


LinearGradientBrush SpreadMethod=Reflect

image_pdfimage_print


   
  


<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">
    <Canvas Width="150" Height="75" Margin="0,0,0,10">
      <Rectangle Width="150" Height="75" Stroke="Black">
        <Rectangle.Fill>
          <LinearGradientBrush StartPoint="0.3,0.5" EndPoint="0.7,0.5" SpreadMethod="Reflect">
            <GradientStop Color="White" Offset="0" />
            <GradientStop Color="#333333" Offset="1" />
          </LinearGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
      <Line X1="45" Y1="40" X2="105" Y2="40"/>
    </Canvas>

</Window>

   
    
     


LinearGradientBrush SpreadMethod=Repeat

image_pdfimage_print


   
  


<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">
    <Canvas Width="150" Height="75" Margin="0,0,0,10">
      <Rectangle Width="150" Height="75" Stroke="Black">
        <Rectangle.Fill>
          <LinearGradientBrush StartPoint="0.3,0.5" EndPoint="0.7,0.5" SpreadMethod="Repeat">
            <GradientStop Color="White" Offset="0" />
            <GradientStop Color="#333333" Offset="1" />
          </LinearGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
      <Line X1="45" Y1="40" X2="105" Y2="40"/>
    </Canvas>

</Window>