Stellen Sie eine FrageStellen Sie eine Frage
 

BeantwortetHow do I get my label to word wrap?

  • Mittwoch, 4. November 2009 16:27B. Clay Shannon TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     

    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

  • Mittwoch, 4. November 2009 17:07B. Clay Shannon TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet
    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

Alle Antworten

  • Mittwoch, 4. November 2009 16:42wjousts TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Put a TextBlock inside your label with TextWrapping set to Wrap
  • Mittwoch, 4. November 2009 17:00B. Clay Shannon TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     

    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
  • Mittwoch, 4. November 2009 17:07B. Clay Shannon TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet
    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
  • Mittwoch, 4. November 2009 18:00wjousts TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     

    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
    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.