WPF 标签内容对齐

发布于 2024-10-03 13:39:12 字数 231 浏览 0 评论 0原文

在WPF标签中,是这样对齐的,如果字体大小增加,则标签大小在右下中增加。

alt text

是否有可能使其在右上方向增加?

附言。

标签包含在 Canvas 中。

In a WPF label, is aligned like this, that if the font size is increased, the label size increases in bottom-right.

alt text

Is there a possibility to make it increase in top-right direction?

PS.

The labels are contained in a Canvas.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

荒岛晴空 2024-10-10 13:39:12

如果您使用 Canvas.Top 指定 Canvas 中的垂直标签位置,则当字体大小增加时,它会向下增长。如果您使用 Canvas.Bottom 指定垂直位置,它将向上生长。 Canvas.Left 和 Canvas.Right 也是如此。

If you specify the Vertical Label position within the Canvas with Canvas.Top it will grow downwards when font-size increases. If you specify Vertical position with Canvas.Bottom it will grow upwards. The same goes for Canvas.Left and Canvas.Right.

撩人痒 2024-10-10 13:39:12

设置控件的 Bottom 和 Left 属性。

<Label Canvas.Bottom="50" Canvas.Left="50">Hello</Label>

Set the Bottom and Left properties of the control.

<Label Canvas.Bottom="50" Canvas.Left="50">Hello</Label>
终陌 2024-10-10 13:39:12

什么样的容器盛放您的标签?

看起来您正在尝试在画布上绘制一个点并添加标签。我建议将两个标签放在一个面板中,以便它们一起缩放,然后将面板放置在画布上的点上。

作为替代方案,您可以考虑在标签上使用 RenderTransform 而不是 FontSize 更改。您可以将标签缩放到更大的尺寸,并设置缩放的中心点来调整其缩放方向。

What sort of container is holding your labels?

It looks like you are trying to plot a point on a canvas and add labels. I'd recommend putting both labels in a single panel so they scale together, then just position the panel at the point on the Canvas.

As an alternative, you could look into using a RenderTransform on your label instead of a FontSize change. You can Scale the label to a larger size, and set the center point of the Scale to adjust what direction it scales in.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文