WPF Label content alignement

Asked by At

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?


The labels are contained in a Canvas.

3 Answers

Fredrik Hedblad On Best Solutions

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.

Rachel On

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.

Crispy On

Set the Bottom and Left properties of the control.

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