方法 : 直線または線分の終点のキャップを変更する
この例では、開いた Shape 要素の始点または終点の形状を変更する方法を示します。 開いた Shape の始点のキャップを変更するには、StrokeStartLineCap プロパティを使用します。 開いた Shape の終点のキャップを変更するには、StrokeEndLineCap プロパティを使用します。 使用できる線キャップを確認するには、PenLineCap 列挙体を参照してください。
![]() |
---|
次の例では、4 つの 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"/>
この例は、より大きなサンプルの一部です。サンプル全体については、図形要素のサンプルを参照してください。