How do I get my label to word wrap?
Here's my xaml:
<Label Name="lblQuestion" Grid.Row="2" FontSize="28" Foreground="Navy" HorizontalAlignment="Stretch" >Some Question?</Label>
The HorizontalAlignment="Stretch" doesn't seem to do diddly squat -- how can I get the label's content to word wrap?
Writer / Photographer - http://www.feedbooks.com/userbook/3631
Antworten
- I simply replaced the label with a TextBlock, and now it works fine:
<TextBlock Name="tbQuestion" Grid.Row="2" FontSize="28" TextWrapping="Wrap" Foreground="Navy" HorizontalAlignment="Stretch" >Some Question?</TextBlock>
Writer / Photographer - http://www.feedbooks.com/userbook/3631- Als Antwort markiertB. Clay Shannon Mittwoch, 4. November 2009 17:07
Alle Antworten
- Put a TextBlock inside your label with TextWrapping set to Wrap
Putting a TextBlock inside the label:
<Label Name="lblQuestion" Grid.Row="2" FontSize="28" Foreground="Navy" HorizontalAlignment="Stretch" >Some Question?
<TextBlock TextWrapping="Wrap" Grid.Row="2"></TextBlock>
</Label>...won't compile.
Putting a TextBlock around the Label:
<TextBlock TextWrapping="Wrap" Grid.Row="2">
<Label Name="lblQuestion" Grid.Row="2" FontSize="28" Foreground="Navy" HorizontalAlignment="Stretch" >Some Question?</Label>
</TextBlock>...did not work.
Writer / Photographer - http://www.feedbooks.com/userbook/3631- I simply replaced the label with a TextBlock, and now it works fine:
<TextBlock Name="tbQuestion" Grid.Row="2" FontSize="28" TextWrapping="Wrap" Foreground="Navy" HorizontalAlignment="Stretch" >Some Question?</TextBlock>
Writer / Photographer - http://www.feedbooks.com/userbook/3631- Als Antwort markiertB. Clay Shannon Mittwoch, 4. November 2009 17:07
No, you can't put text (which WPF will automatically convert to a TextBlock) plus another TextBlock as the child of a label. A Label can only have one child. Put the TextBlock inside the label and the text inside the TextBlock. Or just use the TextBlock by itself if you don't need the additional features of the label.Putting a TextBlock inside the label:
<Label Name="lblQuestion" Grid.Row="2" FontSize="28" Foreground="Navy" HorizontalAlignment="Stretch" >Some Question?
<TextBlock TextWrapping="Wrap" Grid.Row="2"></TextBlock>
</Label>...won't compile.
Putting a TextBlock around the Label:
<TextBlock TextWrapping="Wrap" Grid.Row="2">
<Label Name="lblQuestion" Grid.Row="2" FontSize="28" Foreground="Navy" HorizontalAlignment="Stretch" >Some Question?</Label>
</TextBlock>...did not work.
Writer / Photographer - http://www.feedbooks.com/userbook/3631

