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"/>

相关文章

如何在Silverlight4(XAML)中绑定IsEnabled属性?我试过简单的...
我正在编写我的第一个vb.net应用程序(但我也会在这里标记c#,...
ProcessFile()是在UIThread上运行还是在单独的线程上运行.如...
我从同行那里听说,对sharepoint的了解对职业生涯有益.我们不...
我正在尝试保存一个类我的类对象的集合.我收到一个错误说明:...
我需要根据Silverlight中的某些配置值设置给定控件的Style.我...