I’m implementing a custom control with some labels on it and I need to measure the size of those labels to have an optimal layout. In this way I can properly show the control for each font and font size.
Could you tell me how can I do that, please?
Thank you.
I’m implementing a custom control with some labels on it and I need to
Share
The correct way to size and arrange your custom control according to the size of its sub-elements is to override MeasureOverride and ArrangeOverride.
See the links for details, but in a nutshell, your control is supposed to (in MeasureOverride):
UIElement.Measureon all children (which will include your labels), which will return the size that each of your children would like to have,MeasureOverride).Afterwards, in ArrangeOverride, you get the size allocated to your control by the framework as a parameter and you
UIElement.Arrangeon each child element.