Fill rectangle with Rectangle.Fill tag and LinearGradientBrush

image_pdfimage_print


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

        <Rectangle Canvas.Left = "40" Canvas.Top="40" Width="40" RadiusX="10" RadiusY="10">
            <Rectangle.Fill>
                <LinearGradientBrush>
                    <GradientStop Offset="0" Color="Blue"/>
                    <GradientStop Offset=".8" Color="Yellow"/>
                </LinearGradientBrush>
            </Rectangle.Fill>
        </Rectangle>

    </Canvas>
</Window>