gpt4 book ai didi

c# - 当我们在Grid WPF的右端绘制线条时,线条的StrokeThickness无法正常工作

转载 作者:行者123 更新时间:2023-12-03 15:03:49 24 4
gpt4 key购买 nike

我试图将这条线的StrokeThickness设置为大于1,但是StrokeThickness在网格右侧的行中未正确应用。左侧线工作正常。
程式码片段

<Grid
x:Name="BottomRightPanel"
Width="500"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Yellow">
<Line
x:Name="line"
Stroke="Black"
StrokeThickness="5"
X1="0"
X2="0"
Y1="0"
Y2="50" />
<Line
x:Name="line1"
Stroke="Black"
StrokeThickness="5"
X1="500"
X2="500"
Y1="0"
Y2="50">
</Line>
</Grid>
截屏:
Line is cropped

最佳答案

减小右线的X1和X2值以考虑笔触粗细:

<Line
x:Name="line1"
Stroke="Black"
StrokeThickness="5"
X1="497.5"
X2="497.5"
Y1="0"
Y2="50">
或使用 Border:
<Border Width="500" Background="Yellow"
BorderBrush="Black" BorderThickness="5 0 5 0"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Grid>
<TextBlock />
</Grid>
</Border>

关于c# - 当我们在Grid WPF的右端绘制线条时,线条的StrokeThickness无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62578009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com