This is a migrated thread and some comments may be shown as answers.

How can I have a column with a TextBlock that wraps and supports resizing

2 Answers 36 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jerry Kurata
Top achievements
Rank 1
Jerry Kurata asked on 19 May 2011, 02:46 AM
Hi,

I have a column that contains a ListBox.  The DataTemplate for the listbox contains a couple of controls, one of which is a TextBlock.  I want to have contents of the TextBlock wrap.  So to make that occur I determined that I had to set the width to a specific value.  However, that creates a problem when the user resizes the column.  How can I have the text in the TextBlock wrap AND resize when the user changes the width of the column?


The code I am using is :
<ListBox  Margin="0,5,0,0" x:Name="lstComments" BorderBrush="Transparent"  >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                            <TextBlock TextWrapping="Wrap"  Width=70
                                    Text="{Binding Path=LayoutAnnotation.ANNOTATION.ANNOTATION1}"
// tried this it did not handle resizing
 //                                     Width="{Binding ElementName=lstComments, Path=ActualWidth, Converter={StaticResource /
// AddConverter}, ConverterParameter=-15}"
//
   />
 ...
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

Thanks

Jerry

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 19 May 2011, 07:00 AM
Hi Jerry,

 Why not remove this width and set width for the column itself? 

Greetings,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jerry Kurata
Top achievements
Rank 1
answered on 19 May 2011, 03:33 PM
Vlad,

Are suggesting setting the column width on column creation or resizing?

Thanks,

jerry
Tags
GridView
Asked by
Jerry Kurata
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Jerry Kurata
Top achievements
Rank 1
Share this question
or