Add gradient shape drawing

Add gradient shape drawing

Development tools and key technologies: Visual Studio 2015, WPF
Author: Huang Yuan into
writing time: May 24, 2019

This time we use elliptical shape drawing function to achieve gradual, with the Grid layout, oval (Ellipse) and accompanying Fill (internal instructions how to draw graphics) provided the width and height 150, by setting contour image Stroke red, StrokeThickness (thickness of a graphic outline). If you do not want to write code that can be graded using a shortcut to a key to get the code, the first point to Grid mouse button, select the property next to the steps detailed below:
Here Insert Picture Description
Specific use XAML code to achieve:

<Window x:Class="Wpf1.Window3"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowStartupLocation="CenterScreen"
        Title="Window3" Height="300" Width="300">
    <Grid>
        <Ellipse Height="150" Width="150" Stroke="Red" StrokeThickness="5">
            <Ellipse.Fill>
                <LinearGradientBrush EndPoint="0,0" StartPoint="0,1">
                    <GradientStop Color="White" Offset="0"/>
                    <GradientStop Color="Orchid" Offset="0.25"/>
                    <GradientStop Color="Lavender" Offset="0.5"/>
                    <GradientStop Color="Yellow" Offset="0.75"/>
                </LinearGradientBrush>
            </Ellipse.Fill>
        </Ellipse>
    </Grid>
</Window>

Achieve results is as follows:
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/weixin_44547949/article/details/90520483