简体   繁体   中英

WPF Label content alignment

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

替代文字

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

PS.

The labels are contained in a Canvas .

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.

设置控件的底部和左侧属性。

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM