Path.Data 属性

定义

获取或设置用于指定所要绘制的形状的 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

属性值

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)

注解

若要绘制简单形状,请使用EllipseGeometryLineGeometryRectangleGeometry对象。 若要绘制曲线、弧线或复杂形状,请使用 PathGeometry 对象。 若要创建复合几何图形,请使用 GeometryGroup. 若要组合几何图形,请使用 CombinedGeometry.

XAML 属性元素用法

<Path>  
  <Path.Data>  
    singleGeometry  
  </Path.Data>  
</Path>  

XAML 属性用法

<object Data="moveAndDrawCommands"/>  

XAML 值

singleGeometry
派生自 Geometry的单个对象元素。 可以是以下位置之一:

moveAndDrawCommands
一个或多个移动和绘制命令。 有关完整语法,请参阅 路径标记语法

依赖项属性信息

标识符字段 DataProperty
元数据属性设置为 true AffectsRender, AffectsMeasure

适用于