Nasıl yapılır: PathGeometry İçinde LineSegment Oluşturma
Bu örnekte, bir satır kesiminin nasıl oluşturulacakları gösterir. Bir satır kesimi oluşturmak için PathGeometry , ve PathFigure sınıflarını LineSegment kullanın.
Örnek
Aşağıdaki örnekler LineSegment (10, 50) ile (200, 70) arasında bir alır. Aşağıdaki çizimde elde edilen LineSegment ; koordinat sistemini göstermek için bir kılavuz arka planı eklenmiştir.
(10,50) ile (200,70) arasında çizilen LineSegment
Bir Extensible Application Markup Language (XAML) içinde, bir yolu açıklamak için öznitelik söz dizimi kullanabilirsiniz.
<Path Stroke="Black" StrokeThickness="1"
Data="M 10,50 L 200,70" />
(Bu öznitelik söz dizimlerinin aslında bir StreamGeometry ' nin daha hafif bir sürümünü oluşturduğuna dikkat PathGeometry edin. Daha fazla bilgi için Yol Biçimlendirme Söz Dizimi sayfasına bakın.)
XAML'de, nesne öğesi söz dizimi kullanarak bir satır kesimi de çizebilirsiniz. Aşağıdaki, önceki XAML örneğine eşdeğerdir.
<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="10,50">
<LineSegment Point="200,70" />
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = new Point(10, 50);
LineSegment myLineSegment = new LineSegment();
myLineSegment.Point = new Point(200, 70);
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(myLineSegment);
myPathFigure.Segments = myPathSegmentCollection;
PathFigureCollection myPathFigureCollection = new PathFigureCollection();
myPathFigureCollection.Add(myPathFigure);
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures = myPathFigureCollection;
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
Dim myPathFigure As New PathFigure()
myPathFigure.StartPoint = New Point(10, 50)
Dim myLineSegment As New LineSegment()
myLineSegment.Point = New Point(200, 70)
Dim myPathSegmentCollection As New PathSegmentCollection()
myPathSegmentCollection.Add(myLineSegment)
myPathFigure.Segments = myPathSegmentCollection
Dim myPathFigureCollection As New PathFigureCollection()
myPathFigureCollection.Add(myPathFigure)
Dim myPathGeometry As New PathGeometry()
myPathGeometry.Figures = myPathFigureCollection
Dim myPath As New Path()
myPath.Stroke = Brushes.Black
myPath.StrokeThickness = 1
myPath.Data = myPathGeometry
Bu örnek daha büyük bir örneğin bir parçasıdır; Tam örnek için bkz. Geometriler Örneği.