是否可以在 XAML 中创建一条线(后面没有任何 C# 代码)来对齐布局容器(例如网格)内的线?
我想有效地拥有:
<Grid>
<Line StrokeThickness="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Stroke="Red"/>
</Grid>
我需要使用 StrokeDashArray
和 StrokeDashOffset
,否则我只需使用 Border
控件,并将 BorderThickness 设置为 "0 ,0,0,1"
...
感谢您的任何想法!
最佳答案
为了详细说明 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 - 在纯 XAML 中,是否可以使一条线与网格的一部分对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2430610/