共用方式為


如何:修改線條或線段結尾的端點

此範例會示範如何在開放 Shape 元素的開頭或結尾上修改圖形。 若要變更開放 Shape 的開頭端點,請使用其 StrokeStartLineCap 屬性。 若要變更開放 Shape 的結尾端點,請使用其 StrokeEndLineCap 屬性。 若要檢視可用的線條端點,請參閱 PenLineCap 列舉。

注意

此屬性只會影響開放圖形,例如 LinePolyline 或開放的 Path 元素。

下列範例會繪製四個 Polyline 元素,並在每個元素的結尾使用不同的圖形集。

範例

<TextBlock Grid.Column="3" Grid.Row="0" Grid.ColumnSpan="2">
  <Bold>Line Caps</Bold>
</TextBlock>
<TextBlock Grid.Column="3" Grid.Row="1">Flat</TextBlock>
<Polyline
  Points="50,50 75,30 100,100 130,40"
  Stroke="Red"
  StrokeThickness="20"
  StrokeStartLineCap="Flat"
  StrokeEndLineCap="Flat"
  Grid.Row="1" Grid.Column="4"/>

<TextBlock Grid.Column="3" Grid.Row="2">Square</TextBlock>
<Polyline
  Points="50,50 75,30 100,100 130,40"
  Stroke="Red"
  StrokeThickness="20"
  StrokeStartLineCap="Square"
  StrokeEndLineCap="Square"    
  Grid.Row="2" Grid.Column="4"/>

<TextBlock Grid.Column="3" Grid.Row="3">Round</TextBlock>
<Polyline
  Points="50,50 75,30 100,100 130,40"
  Stroke="Red"
  StrokeThickness="20"
  StrokeStartLineCap="Round"
  StrokeEndLineCap="Round"  
  Grid.Row="3" Grid.Column="4"/>

<TextBlock Grid.Column="3" Grid.Row="4">Triangle</TextBlock>
<Polyline
  Points="50,50 75,30 100,100 130,40"
  Stroke="Red"
  StrokeThickness="20"
  StrokeStartLineCap="Triangle"
  StrokeEndLineCap="Triangle"     
  Grid.Row="4" Grid.Column="4"/>

此範例是較大範例的一部分;如需完整的範例,請參閱圖形元素範例 (英文)。

另請參閱