A Radial Gradient


   
       
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Microsoft.Samples.Graphics.RectangleExample"
    WindowTitle="Example">
  <Canvas>
      <Ellipse Margin="5"  Stroke="Black" StrokeThickness="1">
        <Ellipse.Fill>
          <RadialGradientBrush
             RadiusX="1" RadiusY="1" >
            <GradientStop Color="White" Offset="0" />
            <GradientStop Color="Blue" Offset="1" />
          </RadialGradientBrush>
        </Ellipse.Fill>
      </Ellipse>
      <TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="5">A Radial Gradient</TextBlock>

  </Canvas>
</Page>

   
    
    
    
    
    
    
     


A Partially Transparent Button


   
       
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Microsoft.Samples.Graphics.RectangleExample"
    WindowTitle="Example">
  <Canvas>
      <Button Background="Purple" FontSize="14" FontWeight="Bold">
        <Button.OpacityMask>
          <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
            <GradientStop Offset="0" Color="Black"></GradientStop>
            <GradientStop Offset="1" Color="Transparent"></GradientStop>
          </LinearGradientBrush>
        </Button.OpacityMask>
        <Button.Content>A Partially Transparent Button</Button.Content>
      </Button>

  </Canvas>
</Page>

   
    
    
    
    
    
    
     


Diagonal Linear Gradient


   
       

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Microsoft.Samples.Graphics.RectangleExample"
    WindowTitle="Example">
  <Canvas>
  <Rectangle Width="150" Height="100" Margin="5">
    <Rectangle.Fill>
      <LinearGradientBrush >
        <GradientStop Color="Blue" Offset="0"/>
        <GradientStop Color="White" Offset="1" />
      </LinearGradientBrush>
    </Rectangle.Fill>
  </Rectangle>
    <TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="5">Diagonal Linear Gradient</TextBlock>


  </Canvas>
</Page>

   
    
    
    
    
    
    
     


This text uses a gradient


   
       

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Microsoft.Samples.Graphics.RectangleExample"
    WindowTitle="Example">
  <Canvas>

     <TextBlock Margin="5"  FontWeight="Bold" FontSize="65" TextWrapping="Wrap" TextAlignment="Center">
        <TextBlock.Text>This text uses a gradient.</TextBlock.Text>
        <TextBlock.Foreground>
          <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
            <GradientStop Color="Yellow" Offset="0.0" />
            <GradientStop Color="Red" Offset="0.25" />
            <GradientStop Color="Blue" Offset="0.75" />
            <GradientStop Color="LimeGreen" Offset="1.0" />
          </LinearGradientBrush>
        </TextBlock.Foreground>
      </TextBlock>
  </Canvas>
</Page>

   
    
    
    
    
    
    
     


using Color structures


   
       

<Window x:Class="WpfApplication1.ShapesWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ShapesWindow" Height="160" Width="400">
      <Window.Resources>
        <Style TargetType="{x:Type Rectangle}">
          
          <!-- Gives all the rectangles in this panel a white stroke. -->
          <Setter Property="Stroke" Value="White"/>
          <Setter Property="StrokeThickness" Value="1"/>
        </Style>
      </Window.Resources>
    <Canvas>

      <Rectangle Width="50" Height="50">
        <Rectangle.Fill>
          <SolidColorBrush>
            <SolidColorBrush.Color>

              <!-- Describes the brush&#039;s color using
                    ScRGB values. Each value has a range
                    of 0-1.  -->
              <Color ScA="1.0" ScR="0.0" ScG="0.0" ScB="1.0" />
            </SolidColorBrush.Color>
          </SolidColorBrush>
        </Rectangle.Fill>
      </Rectangle>

    </Canvas>
</Window>

   
    
    
    
    
    
    
     


Highlights the gradient origin and the gradient circle

   
       

<Window x:Class="WpfApplication1.ShapesWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ShapesWindow" Height="160" Width="400">

    <StackPanel>

    <Canvas ClipToBounds="True" Grid.Row="3" Grid.Column="2" Width="150" Height="150">
      <Rectangle Width="150" Height="150">
        <Rectangle.Fill>
          <RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.1,0.1" RadiusX="0.75" RadiusY="0.75">
            <GradientStop Color="White" Offset="0" />
            <GradientStop Color="#545454" Offset="1" />
          </RadialGradientBrush>
        </Rectangle.Fill>
      </Rectangle>ss
      <Path Fill="Red">
        <Path.Data>
          <EllipseGeometry Center="75,75" RadiusX="2" RadiusY="2" />
        </Path.Data>
      </Path>
      <Path Stroke="Red" StrokeThickness="2">
        <Path.Data>
          <EllipseGeometry Center="15,15" RadiusX="111.5" RadiusY="111.5" />
        </Path.Data>
      </Path>
    </Canvas>

    </StackPanel>
</Window>