線の幅を変更するには BorderThicknessプロパティを使用します。
BorderThicknessプロパティはThickness型のプロパティで、4辺すべてを同じ幅に設定したり、各辺それぞれの幅を指定することも可能です。
下記は線の幅を指定する例です。
border1はすべての辺の幅を2に指定し、border2は各辺の幅をそれぞれ指定しています。
<!-- 4辺の幅をすべて2に設定 --> <Border x:Name="border1" BorderThickness="2" HorizontalAlignment="Left" BorderBrush="Black" Height="100" Margin="10,10,0,0" VerticalAlignment="Top" Width="100"/> <!-- 左2, 上4, 右6, 下8に設定 --> <Border x:Name="border2" BorderThickness="2,4,6,8" HorizontalAlignment="Left" BorderBrush="Black" Height="100" Margin="115,10,0,0" VerticalAlignment="Top" Width="100"/>
C#での設定例を以下に示します。
// 4辺の幅を5に指定 border1.BorderThickness = new Thickness(5); // 左2,上4,右6,下8に設定 border2.BorderThickness = new Thickness(2.0f, 4.0f, 6.0f, 8.0f);
Please follow and like us:
コメント