Formular una preguntaFormular una pregunta
 

RespondidaHow do I get my label to word wrap?

  • miércoles, 04 de noviembre de 2009 16:27B. Clay Shannon Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    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

Respuestas

  • miércoles, 04 de noviembre de 2009 17:07B. Clay Shannon Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida
    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
    • Marcado como respuestaB. Clay Shannon miércoles, 04 de noviembre de 2009 17:07
    •  

Todas las respuestas

  • miércoles, 04 de noviembre de 2009 16:42wjousts Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    Put a TextBlock inside your label with TextWrapping set to Wrap
  • miércoles, 04 de noviembre de 2009 17:00B. Clay Shannon Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    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
  • miércoles, 04 de noviembre de 2009 17:07B. Clay Shannon Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida
    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
    • Marcado como respuestaB. Clay Shannon miércoles, 04 de noviembre de 2009 17:07
    •  
  • miércoles, 04 de noviembre de 2009 18:00wjousts Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    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.