I. The following is a one-on-one explanation:
1. Straight Line
A straight line is the simplest image. You can use the X1 and Y1 attributes to set the start coordinate. The X2 and Y2 attributes are used to set the end coordinate. You can control the coordinates of the start and end points to achieve parallel and staggered effects. The data type of the Stroke attribute is a Brush. Any derived class of the Brush can be used to assign values to this attribute. Since WPF provides a variety of gradient paint brushes, you can draw gradient effects in a straight line. At the same time, some Line attributes also help us draw dotted lines and control the shape of the end point of a Line segment.
The following examples combine these attributes:
<Window x: Class = "WpfApplication1.MainWindow"
Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
Title = "Lines" Height = "260" Width = "300">
<Grid>
<Line X1 = "10" Y1 = "20" X2 = "260" Y2 = "20"/>
<Line X1 = "10" Y1 = "40" X2 = "260" Y2 = "40" Stroke = "Orange" StrokeThickness = "6"/>
<Line X1 = "10" Y1 = "60" X2 = "260" Y2 = "60" Stroke = "Green" StrokeThickness = "3"/>
<Line X1 = "10" Y1 = "80" X2 = "260" Y2 = "80" Stroke = "Purple" StrokeThickness = "2"/>
<Line X1 = "10" Y1 = "100" X2 = "260" Y2 = "100" Stroke = "Black" StrokeThickness = "1"/>
<Line X1 = "10" Y1 = "120" X2 = "260" Y2 = "120" StrokeDashArray = "3" Stroke = "Black" StrokeThickness = "1"/>
<Line X1 = "10" Y1 = "140" X2 = "260" Y2 = "140" StrokeDashArray = "5" Stroke = "Black" StrokeThickness = "1"/>
<Line X1 = "10" Y1 = "160" X2 = "260" Y2 = "160" Stroke = "Black" StrokeEndLineCap = "Flat" StrokeThickness = "6"/>
<Line X1 = "10" Y1 = "180" X2 = "260" Y2 = "180" Stroke = "Black" StrokeEndLineCap = "Triangle" StrokeThickness = "8"/>
<Line X1 = "10" Y1 = "200" X2 = "260" Y2 = "200" StrokeEndLineCap = "Round" StrokeThickness = "10">
<Line. Stroke>
<LinearGradientBrush EndPoint = "0, 0.5" StartPoint = "1, 0.5">
<GradientStop Color = "Blue"/>
<GradientStop Offset = "1"/>
</LinearGradientBrush>
</Line. Stroke>
</Line>
</Grid>
</Window>
The actual result 1 is as follows:
From the wangganggang90 Column