Path.Data 属性
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置用于指定所要绘制的形状的 Geometry
public:
property System::Windows::Media::Geometry ^ Data { System::Windows::Media::Geometry ^ get(); void set(System::Windows::Media::Geometry ^ value); };
public System.Windows.Media.Geometry Data { get; set; }
member this.Data : System.Windows.Media.Geometry with get, set
Public Property Data As Geometry
所要绘制的形状的描述。
以下示例演示如何使用代码创建 Path 元素并设置 Data 属性。
//Add the Path Element
myPath = gcnew Path();
myPath->Stroke = Brushes::Black;
myPath->Fill = Brushes::MediumSlateBlue;
myPath->StrokeThickness = 4;
myPath->HorizontalAlignment = HorizontalAlignment::Left;
myPath->VerticalAlignment = VerticalAlignment::Center;
EllipseGeometry^ myEllipseGeometry = gcnew EllipseGeometry();
myEllipseGeometry->Center = Point(50, 50);
myEllipseGeometry->RadiusX = 25;
myEllipseGeometry->RadiusY = 25;
myPath->Data = myEllipseGeometry;
myGrid->Children->Add(myPath);
//Add the Path Element
myPath = new Path();
myPath.Stroke = System.Windows.Media.Brushes.Black;
myPath.Fill = System.Windows.Media.Brushes.MediumSlateBlue;
myPath.StrokeThickness = 4;
myPath.HorizontalAlignment = HorizontalAlignment.Left;
myPath.VerticalAlignment = VerticalAlignment.Center;
EllipseGeometry myEllipseGeometry = new EllipseGeometry();
myEllipseGeometry.Center = new System.Windows.Point(50,50);
myEllipseGeometry.RadiusX = 25;
myEllipseGeometry.RadiusY = 25;
myPath.Data = myEllipseGeometry;
myGrid.Children.Add(myPath);
' Add a Path Element
Dim myPath As New Path()
myPath.Stroke = Brushes.Black
myPath.Fill = Brushes.MediumSlateBlue
myPath.StrokeThickness = 4
myPath.HorizontalAlignment = HorizontalAlignment.Left
myPath.VerticalAlignment = VerticalAlignment.Center
Dim myEllipseGeometry As New EllipseGeometry()
myEllipseGeometry.Center = New System.Windows.Point(50, 50)
myEllipseGeometry.RadiusX = 25
myEllipseGeometry.RadiusY = 25
myPath.Data = myEllipseGeometry
myGrid.Children.Add(myPath)
若要绘制简单形状,请使用EllipseGeometry和LineGeometryRectangleGeometry对象。 若要绘制曲线、弧线或复杂形状,请使用 PathGeometry 对象。 若要创建复合几何图形,请使用 GeometryGroup. 若要组合几何图形,请使用 CombinedGeometry.
<Path>
<Path.Data>
singleGeometry
</Path.Data>
</Path>
<object Data="moveAndDrawCommands"/>
singleGeometry
派生自 Geometry的单个对象元素。 可以是以下位置之一:
简单几何图形 EllipseGeometry之一, LineGeometry或 RectangleGeometry。
一个 GeometryGroup,它支持其他几何图形作为子元素。 请参阅 XAML 值部分了解 GeometryGroup。
A PathGeometry,它支持建立图形和段的路径几何对象模型子对象元素。 请参阅 XAML 值部分了解 PathGeometry。
moveAndDrawCommands
一个或多个移动和绘制命令。 有关完整语法,请参阅 路径标记语法。
标识符字段 | DataProperty |
元数据属性设置为 true |
AffectsRender, AffectsMeasure |
产品 | 版本 |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
Windows Desktop | 3.0, 3.1, 5, 6, 7 |