本範例示範如何使用 LineGeometry 類別來描述線條。 LineGeometry 的定義必須包含一個起始點以及一個結束點。
範例
下列範例顯示如何建立和呈現 LineGeometry。 Path 項目可用來呈現線條。 因為線條沒有面積,所以沒有指定 Path 物件的 Fill;而改用 Stroke 和 StrokeThickness 屬性。
<Path Stroke="Black" StrokeThickness="1" >
<Path.Data>
<LineGeometry StartPoint="10,20" EndPoint="100,130" />
</Path.Data>
</Path>
Dim myLineGeometry As New LineGeometry()
myLineGeometry.StartPoint = New Point(10,20)
myLineGeometry.EndPoint = New Point(100,130)
Dim myPath As New Path()
myPath.Stroke = Brushes.Black
myPath.StrokeThickness = 1
myPath.Data = myLineGeometry
LineGeometry myLineGeometry = new LineGeometry();
myLineGeometry.StartPoint = new Point(10,20);
myLineGeometry.EndPoint = new Point(100,130);
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myLineGeometry;
從 (10,20) 繪製至 (100,130) 的 LineGeometry
.gif)
其他簡單的幾何類別包括 LineGeometry 和 EllipseGeometry。 這些幾何,以及更複雜的幾何,也都可以使用 PathGeometry 或 StreamGeometry 來建立。 如需詳細資訊,請參閱 幾何概觀。