扩展 WPF 标签的大小
我在 StackPanel 中有几个 Label 控件,它们的宽度设置为 Auto。但是,标签的宽度不会扩展以利用 StackPanel 中 100% 的可用空间。我怎样才能做到这一点?谢谢。
编辑:好的,我发现问题是因为我有一个 AccessText 属性。因此,即使 HorizontalAlignment 设置为 Stretch,我的标签仍在扩展,但 AccessText 并未扩展。
I have several Label controls inside a StackPanel and their width is set to Auto. However, the width of the label does not extend to utilize 100% of the space available in the StackPanel. How can I accomplish this? Thanks.
EDIT: Ok I found out the problem is because I have an AccessText property. So my label is expanding but AccessText is not, even when HorizontalAlignment is set to Stretch.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
自动意味着如果水平对齐方式为居中,标签将占用文本所需的空间。您需要将水平对齐设置为拉伸,以使其占据整个宽度。
Auto means that the label will take up just as much space is needed for the text if Horizontal Alignment is center. You will need to set the Horizontal Alignment to stretch for it to take up the entire width.
将
HorizontalAlignment
设置为Stretch
。Set
HorizontalAlignment
toStretch
.我设置了以下属性,它对我有用。
I set following properties and it worked for me.