是否可以在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"/>