我怎样才能让这个边境的Silverlight元素的下边框有一个红色的点缀里面红色的实行?
边境边境=新的边界();
border.CornerRadius =新CornerRadius(5);
border.BorderThickness =新厚度(0,0,0,1);
border.BorderBrush =新的SolidColorBrush(Colors.Red);
解决方案
你能有一个网格替换的边界,并给它一个矩形覆盖整个区域?
<矩形拉伸=填充半径=10半径=10StrokeDashArray =10 2中风=黑补=白/>
该StrokeDashArray可以用来绘制点缀而是一个边界没有这样的属性。
编辑:
由于我注意到你只是点缀下边框你可以做这样的事情
<边框宽度=100高度=100背景=蓝了borderThickness =0,0,0,1>
< Border.BorderBrush>
<2,0一个LinearGradientBrush StartPoint可以=0,0的EndPoint = S preadMethod =重复>
< GradientStopCollection>
<渐变停止颜色=透明偏移量=0/>
<渐变停止颜色=透明偏移=0.3/>
<渐变停止颜色=红偏移=0.3/>
<渐变停止颜色=红偏移=0.6/>
<渐变停止颜色=透明偏移=0.6/>
<渐变停止颜色=透明偏移=1/>
< / GradientStopCollection>
< /一个LinearGradientBrush>
< /Border.BorderBrush>
< /边框>
调整偏移
的中间两个渐变停止的调整红点/破折号的宽度。您可能还需要调整的终结点,使其重复你想要的时间间隔。
How can I make the bottom border of this Border Silverlight element have a red dotted inside of a red solid line?
Border border = new Border();
border.CornerRadius = new CornerRadius(5);
border.BorderThickness = new Thickness(0, 0, 0, 1);
border.BorderBrush = new SolidColorBrush(Colors.Red);
解决方案
Can you replace the border with a Grid and give it a Rectangle that fills the whole area?
<Rectangle Stretch="Fill" RadiusX="10" RadiusY="10" StrokeDashArray="10, 2" Stroke="Black" Fill="White" />
The StrokeDashArray can be used to draw it dotted but a Border has no such property.
EDIT:
Since I noticed you are only dotting the bottom border you could do something like this
<Border Width="100" Height="100" Background="Blue" BorderThickness="0,0,0,1">
<Border.BorderBrush>
<LinearGradientBrush StartPoint="0,0" EndPoint=".2,0" SpreadMethod="Repeat" >
<GradientStopCollection>
<GradientStop Color="Transparent" Offset="0" />
<GradientStop Color="Transparent" Offset="0.3" />
<GradientStop Color="Red" Offset="0.3" />
<GradientStop Color="Red" Offset="0.6" />
<GradientStop Color="Transparent" Offset="0.6" />
<GradientStop Color="Transparent" Offset="1" />
</GradientStopCollection>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
Adjust the Offset
of the middle two GradientStop's to adjust the width of the red dot/dash. You may also need to adjust the endpoint to make it repeat at your desired interval.