Udostępnij za pośrednictwem


Path.Data Właściwość

Definicja

Pobiera lub ustawia Geometry element, który określa kształt do narysowania.

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

Wartość właściwości

Opis kształtu, który ma zostać narysowany.

Przykłady

W poniższym przykładzie pokazano, jak utworzyć Path element i ustawić Data właściwość przy użyciu kodu.


//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)

Uwagi

Aby narysować proste kształty, użyj EllipseGeometryobiektów , LineGeometryi RectangleGeometry . Aby narysować krzywe, łuki lub złożone kształty, użyj PathGeometry obiektu . Aby utworzyć geometrię złożoną, użyj elementu GeometryGroup. Aby połączyć geometrie, użyj elementu CombinedGeometry.

Użycie elementu właściwości XAML

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

Użycie atrybutu XAML

<object Data="moveAndDrawCommands"/>

Wartości XAML

singleGeometry Pojedynczy element obiektu, który pochodzi z klasy Geometry. Może to być jeden z następujących elementów:

moveAndDrawCommands Co najmniej jedno polecenie przenoszenia i rysuj. Aby uzyskać pełną składnię, zobacz Path Markup Syntax (Składnia znaczników ścieżki).

Informacje o właściwości zależności

Produkt Wartość
Pole identyfikatora DataProperty
Właściwości metadanych ustawione na true AffectsRender, AffectsMeasure

Dotyczy