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

1 column grid with text wrap

1 Answer 125 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 2
Jonathan asked on 22 Nov 2010, 06:12 PM
I have a radgridview like following:

<telerik:RadGridView x:Name="_Grid"
                     IsFilteringAllowed="False"
                     IsReadOnly="True"
                     SelectionMode="Single"
                     ShowGroupPanel="False"
                     ItemsSource="{Binding}"
                     Grid.Row="7"
                     CanUserInsertRows="False"
                     AlternationCount="2"
                     ActionOnLostFocus="None"
                     AutoGenerateColumns="False"
                     Margin="5"
                     VerticalAlignment="Stretch"
                     ShowColumnFooters="False"
                     CanUserFreezeColumns="False"
                     HorizontalAlignment="Stretch"
                     >
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="Bookmarks" DataMemberBinding="{Binding BookMarkText}" TextWrapping="Wrap">
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <Grid HorizontalAlignment="Stretch">
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock TextWrapping="Wrap" Text="{Binding BookMarkText}" Style="{StaticResource FieldLabelTextBlock}" />
                        <TextBlock TextWrapping="Wrap" Grid.Row="1" Text="{Binding Description}" HorizontalAlignment="Stretch"/>
                    </Grid>
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>
    </telerik:RadGridView.Columns>
 
</telerik:RadGridView>

ie a grid with only a single column and cells with content that (I wish) wraps in the available horizontal space. However the content continues "off the screen" and a horizontal scroll bar appears instead. (screenshot, left)

I can't hard code the width of the grid or the column, as it is in a user-adjustable pane.

Furthermore, if I increase the width of the pane, an additional, "dummy" column is added (screenshot, right)

How can I have the text in the grid wrap (highest priority)?
How can I not have the "dummy" column appear (not a major issue)?

Assistance appreciated

Jonathan

1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 23 Nov 2010, 10:04 AM
Hi Jonathan,

I have managed to achieve the desired effect by changing a little bit your own project. This declaration of DataTemplate fixes the text wrapping issue. As the "dummy" column is concerned, you should use "*" width to your single column to let it flow fully into all the space available. I am attaching you my project to throw some more light upon my solution.

Greetings,
Ivan X1
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
GridView
Asked by
Jonathan
Top achievements
Rank 2
Answers by
Ivan Ivanov
Telerik team
Share this question
or