Resizing issues with RadGridView with Custom CellTemplate

3 posts, 0 answers
  1. Remo Garropoli
    Remo Garropoli avatar
    8 posts
    Member since:
    May 2007

    Posted 20 Nov 2014 Link to this post

    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. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 20 Nov 2014 Link to this post

    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.

     
  3. Remo Garropoli
    Remo Garropoli avatar
    8 posts
    Member since:
    May 2007

    Posted 20 Nov 2014 in reply to Vanya Pavlova Link to this post

    Thanks very much. now it works

Back to Top