共用方式為


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 Attribute Usage

<object Data="moveAndDrawCommands"/>  

XAML 值

singleGeometry
衍生自 Geometry 的單一物件專案。 這可以是下列項目之一:

moveAndDrawCommands
一或多個移動和繪製命令。 如需完整的語法,請參閱 路徑標記語法

相依性屬性資訊

識別碼欄位 DataProperty
設定為 的中繼資料屬性 true AffectsRender, AffectsMeasure

適用於