silverlight – 在纯XAML中,是否可以使一条线与网格的一部分对齐?

前端之家收集整理的这篇文章主要介绍了silverlight – 在纯XAML中,是否可以使一条线与网格的一部分对齐?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
是否可以在XAML中创建一个Line(后面没有任何C#代码)来对齐一个布局容器(如Grid)中的一行?

我想有效地:

<Grid>
    <Line StrokeThickness="1" 
          HorizontalAlignment="Stretch" 
          VerticalAlignment="Bottom" 
          Stroke="Red"/>
</Grid>

我需要使用StrokeDashArray和StrokeDashOffset,否则我只会使用BorderThickness设置为“0,1”的Border控件…

谢谢你的任何想法!

解决方法

要详细说明kanchirk的回应,这对我有用:

<Path StrokeThickness="1"
 HorizontalAlignment="Stretch"  
 VerticalAlignment="Bottom"
 Data="M0,0 L1,0"
 Stretch="Fill"
 StrokeEndLineCap="Square"
 StrokeStartLineCap="Square"
 Stroke="Red"/>

你也可以用Line做同样的事情:

<Line StrokeThickness="1" 
 HorizontalAlignment="Stretch"   
 VerticalAlignment="Bottom" 
 X2="1" 
 Stretch="Fill" 
 StrokeEndLineCap="Square" 
 StrokeStartLineCap="Square" 
 Stroke="Red"/>

猜你在找的Silverlight相关文章