locked
Wrap Text in Listbox RRS feed

  • Question

  •  I have a textBlock in my ListBox and I would like to wrap it wo the width of the Listbox. I tried adding a Width = "180" to the TextBlock, but then, my Name String just gets cut...How do I wrap the text so that I won't get a ScrollBar on the buttom?

    	<ListBox Height="110" Width="181" x:Name="FormularListBox" Background="{x:Null}" BorderBrush="{x:Null}">
                            <ListBox.ItemTemplate>
    
                                <DataTemplate>
    
                                    <StackPanel>
    
                                        <TextBlock Text="{Binding Name}" Margin="5"/>
    
                                    </StackPanel>
    
                                </DataTemplate>
    
                                </ListBox.ItemTemplate>
                                <ListBox.Foreground>
                                    <SolidColorBrush Color="{StaticResource BorderColor}"/>
                                </ListBox.Foreground>
                            </ListBox>
                        
     
    Thursday, May 14, 2009 7:47 AM

Answers

  • <TextBlock Text="{Binding Name}" Margin="5" TextWrapping="Wrap" />

    HTH

    Thursday, May 14, 2009 8:21 AM

All replies