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

Resizing issues with RadGridView with Custom CellTemplate

2 Answers 150 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Remo Garropoli
Top achievements
Rank 1
Remo Garropoli asked on 20 Nov 2014, 10:34 AM
Hello everybody

I have a problem with radgridview row resizing when this propterty is enabled.
I don't know how to transfer the change of RowHeight  to controls inside a DataTemplate like this

                <telerik:GridViewDataColumn DataMemberBinding="{Binding text1}" Header="Data Template" >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="some letter" VerticalContentAlignment="Stretch" Margin="0" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>

When I resizing the row the height of textBox is always the same, centered in the row.
This behavior is visible in the image annex to this Thread.
I would like the height of the TextBox to follow the row height of the RadGridView (stretched vertically)

thanks in advance

2 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 20 Nov 2014, 04:35 PM
Hello Remo,


You could define a style targeted at GridViewCell and set its VerticalContentAlignment property to Stretch, as proposed below:

<Window.Resources>
        <Style x:Key="style" TargetType="telerik:GridViewCell" BasedOn="{StaticResource GridViewCellStyle}">
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
      </Style>
        </Window.Resources>
    <Grid DataContext="{Binding Source={StaticResource SampleDataSource}}">
        <telerik:RadGridView CanUserResizeRows="True" ItemsSource="{Binding Collection}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding text1}" CellStyle="{StaticResource style}" Header="Data Template" >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="some letter" VerticalContentAlignment="Stretch" Margin="0" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>



Regards,
Vanya Pavlova
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Remo Garropoli
Top achievements
Rank 1
answered on 20 Nov 2014, 05:37 PM
Thanks very much. now it works

Tags
GridView
Asked by
Remo Garropoli
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Remo Garropoli
Top achievements
Rank 1
Share this question
or