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、 LineGeometry和 RectangleGeometry 物件。 要畫曲線、弧線或複雜形狀,請使用物件。PathGeometry 要建立複合幾何,請使用 GeometryGroup. 要結合幾何形狀,請使用 CombinedGeometry.
XAML 屬性元素的使用
<Path>
<Path.Data>
singleGeometry
</Path.Data>
</Path>
XAML 屬性使用方式
<object Data="moveAndDrawCommands"/>
XAML 值
單一幾何 一個由 衍生的 Geometry單一物件元素。 這個權限可以是下列其中一項:
其中一種簡單的幾何形狀 EllipseGeometry, , LineGeometry或 RectangleGeometry。
一個 GeometryGroup單一的 ,作為子元素支援其他幾何體。 請參閱 XAML 值章節。GeometryGroup
A PathGeometry,支援子物件元素,建立圖形與段的路徑幾何物件模型。 請參閱 XAML 值章節。PathGeometry
移動與繪製指令 一個或多個移動與拔牌指令。 完整語法請參見 路徑標記語法。
相依財產資訊
| 項目 | 價值 |
|---|---|
| 識別碼欄位 | DataProperty |
元資料屬性設為 true |
AffectsRender、AffectsMeasure |