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

RadGridView Column With Auto Zoom

1 Answer 22 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
w asked on 23 Oct 2018, 02:20 PM


    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" >
                        <Style TargetType="{x:Type telerik:GridViewCell}" BasedOn="{StaticResource GridViewCellStyle}">
                            <Setter Property="ContentTemplate">
                                        <StackPanel Orientation="Horizontal">
                                            <CheckBox x:Name="checkBox"/>
                                            <TextBlock x:Name="textBlockA" Text="AAAAAAA"/>
                                            <TextBlock x:Name="textBlockB" Text="BBBBBBB"/>
                                            <DataTrigger Binding="{Binding ElementName=checkBox,Path=IsChecked}" Value="false">
                                                <Setter TargetName="textBlockB" Property="Visibility" Value="Collapsed"/>

    I use your demo do a test about gridviewcolumn width, As the attach video show. 

 When I check the checkBox in column style,the column with stretch automatically, 

 when I unchecked, the column width  do not get shorter. Is there any method make the column get shorter When I unchecked in the NameColumn

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 26 Oct 2018, 10:17 AM

Thank you for the provided attached files.

I would suggest you instead of specifying the hiding and showing a TextBlock in the ContentTemplate of the cell, to create a custom DataTemplate and set it to the CellTemplate property of the column. Then you can bind the CheckBox IsChecked property and the Text property of a TextBlock. The next step is to change the Text depending on the IsChecked property of the CheckBox. I have modified your project to demonstrate this approach.

Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question