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

RadGridView Column With Auto Zoom

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

Hi,

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

    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
0
Dinko | Tech Support Engineer
Telerik team
answered on 26 Oct 2018, 10:17 AM
Hi,

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.

Regards,
Dinko
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.
Tags
GridView
Asked by
w
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or