Path最重要的属性是Data,Data的数据类型是Geometry(是抽象类,要用派生类的标签),赋值方法有两种,一种是标签式标准语法,第二种是路径标记语法。
基础知识
Geometry的子类有:
LineGeometry:直线几何图形
RectangleGeometry:矩形几何图形
EllipseGeometry
PathGeometry
StreamGeometry:PathGeometry的轻量级替代品,不支持Binding、动画等
CombinedGeometry:由多个基本几何图形联合在一起,形成的单一几何图形
GeometryGroup:这个是一组,不是单一图形
前面的Line/Rectangle/Ellipse类都是可以独立存在的对象,而LineGeometry这些只能用于结合成其他几何图形,不能独立存在。当在Blend中选一组独立的几何图形并在菜单里执行组合路径的命令时,本质是把原本独立的Line/Rectangle/Ellipse变成了*Geometry对象,然后组合成一个新的复杂图形。

绘制<PathFigure.Segments>时,这些线段都没有起点,因为起点就是前一个线段的终点。第一个线段的起点是PathFigure的StartPoint。
Path实例:标签定义

<UserControl x:Class="pxy.PathLabelBasic"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:pxy"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="400">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160"/>
<ColumnDefinition Width

1万+

被折叠的 条评论
为什么被折叠?



