I have a label that is binded to something. I want the label to expand in width and height if the string is too long, so that it fits on screen.
I had this:
<StackPanel Orientation="Horizontal" Margin="0,0,0,200" Height="50" Width="900">
<Label HorizontalContentAlignment="Left" VerticalAlignment="Center" Padding="5" FontSize="24" Content="Instruction: " Width="290" />
<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="25" Text="{Binding InstructionLabel}" Width="auto" Height="auto" />
</StackPanel>
Notice that I tried using a TextBlock instead of a Label. This didn't work tough, so I tried:
<Label HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="25" Width="auto" Height="auto">
<AccessText TextWrapping="WrapWithOverflow" Text="{Binding InstructionLabel}"/>
</Label>
But this doesn't work either.
The View is now like this:
just give the MaxWidth of your TextBlock
<StackPanel Orientation="Horizontal" Margin="0,0,0,200" Height="50" Width="900">
<Label HorizontalContentAlignment="Left" VerticalAlignment="Center" Padding="5" FontSize="24" Content="Instruction: " Width="290" />
<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" MaxWidth="100" VerticalAlignment="Top" FontSize="25" Text="{Binding InstructionLabel}" Width="auto" Height="auto" />
</StackPanel>
and then your textwrapping will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With