In the previous section, we have done the most complex pathgeometry, and it is good to have a few other guys. Come and see their real faces.
1. linegeometry
This ry is simple. A line segment contains two points: startpoint and endpoint.
Let's take a look at the following example.
<Path Grid.Column = "0" Grid.Row = "0">
<Path.Data>
<LineGeometry StartPoint = "20,5" EndPoint = "200,320" />
</Path.Data>
</ Path>
After running, you will see the following scenario:
Second, RectangleGeometry
It presents a person ’s rectangular geometry. Rect indicates the position and size of the rectangle. In XAML, it can be represented by 4 values, namely X, Y, Width, and Height; otherwise, RadiusX and RadiusY indicate rounded corners on the X and Y axes. On the radius. See the example below.
<Path Grid.Column = "1" Grid.Row = "0">
<Path.Data>
<RectangleGeometry Rect = "12,6,125,90" RadiusX = "24" RadiusY = "30" />
</Path.Data>
</ Path>
The running effect is as shown.
3. EllipseGeometry
Represents the geometry of an ellipse, the Center property is the coordinates of the center point of the ellipse, RadiusX and RadiusY are the radius length in the X-axis direction and the Y-axis direction, respectively. See examples.
<Path Grid.Column = "0" Grid.Row = "1">
<Path.Data>
<EllipseGeometry Center = "100,180" RadiusX = "55" RadiusY = "120" />
</Path.Data>
</ Path>
The running effect is as follows:
Four, GeometryGroup
Strictly speaking, it does not attribute a geometric figure, but it is very useful because it can contain N geometric figures at the same time, as shown in the following example.
<Path Grid.Column = "1" Grid.Row = "1">
<Path.Data>
<GeometryGroup>
<LineGeometry StartPoint = "32,185" EndPoint = "180,230" />
<RectangleGeometry Rect = "35,85,136,96" RadiusX = "25" RadiusY = "5" />
<EllipseGeometry Center = "112,130" RadiusX = "45" RadiusY = "36" />
</ GeometryGroup>
</Path.Data>
</ Path>
The operating effect is as follows:
Below is the complete XAML code for the example in this section.
<phone: PhoneApplicationPage
x: Class = "Sample.MainPage"
xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
xmlns: phone = "clr-namespace: Microsoft.Phone.Controls; assembly = Microsoft.Phone"
xmlns: shell = "clr-namespace: Microsoft.Phone.Shell; assembly = Microsoft.Phone"
xmlns: d = "http://schemas.microsoft.com/expression/blend/2008"
xmlns: mc = "http://schemas.openxmlformats.org/markup-compatibility/2006"
mc: Ignorable = "d" d: DesignWidth = "480" d: DesignHeight = "768"
FontFamily = "{StaticResource PhoneFontFamilyNormal}"
FontSize = "{StaticResource PhoneFontSizeNormal}"
Foreground = "{StaticResource PhoneForegroundBrush}"
SupportedOrientations = "Portrait" Orientation = "Portrait"
shell: SystemTray.IsVisible = "True">
<phone: PhoneApplicationPage.Resources>
<Style TargetType = "Path">
<Setter Property = "HorizontalAlignment" Value = "Stretch" />
<Setter Property = "VerticalAlignment" Value = "Stretch" />
<Setter Property = "Margin" Value = "20" />
<Setter Property = "Stroke" Value = "Blue" />
<Setter Property = "StrokeThickness" Value = "8" />
</ Style>
</phone:PhoneApplicationPage.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width = "*" />
<ColumnDefinition Width = "*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height = "*" />
<RowDefinition Height = "*" />
</Grid.RowDefinitions>
<Path Grid.Column = "0" Grid.Row = "0">
<Path.Data>
<LineGeometry StartPoint = "20,5" EndPoint = "200,320" />
</Path.Data>
</ Path>
<Path Grid.Column = "1" Grid.Row = "0">
<Path.Data>
<RectangleGeometry Rect = "12,6,125,90" RadiusX = "24" RadiusY = "30" />
</Path.Data>
</ Path>
<Path Grid.Column = "0" Grid.Row = "1">
<Path.Data>
<EllipseGeometry Center = "100,180" RadiusX = "55" RadiusY = "120" />
</Path.Data>
</ Path>
<Path Grid.Column = "1" Grid.Row = "1">
<Path.Data>
<GeometryGroup>
<LineGeometry StartPoint = "32,185" EndPoint = "180,230" />
<RectangleGeometry Rect = "35,85,136,96" RadiusX = "25" RadiusY = "5" />
<EllipseGeometry Center = "112,130" RadiusX = "45" RadiusY = "36" />
</ GeometryGroup>
</Path.Data>
</ Path>
</ Grid>
</ phone: PhoneApplicationPage>