Hello, I have this problem. I need to know the size a Label is trying to use, but since the control that contains it is smaller than the actual label, when I call label.ActualWidth, what I really get is the width of said container control. Is there a way to get the width that the label would require to fit its content (disregarding its ACTUAL width)? Something like label.RequiredWidth, neither label.DesiredSize.Width or label.ActualWidth work.
Here's what I'm trying:
XAML:
<StackPanel Width="100">
<Label x:Name="aLabel">Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text </Label>
</StackPanel>
C#:
aLabel.ActualWidth; // this is 100 like the StackPanel
aLabel.DesiredSize.Width; // also 100 like the StackPanel
Thank you.