Posted 16 Jun 2011 Link to this post
Can you verify if your view-model implements INotifyPropertyChanged properly?
The DataContext for columns (and the grid itself) is your view-model - not the entities. Your entities will be set as DataContext for rows/cells.
Posted 23 Jan 2012 Link to this post
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Col1" DataMemberBinding="{Binding Col1}" IsGroupable="False" IsFilterable="True" ShowDistinctFilters="False" IsVisible="{Binding ElementName=chk1, Path=IsChecked}" />
<telerik:GridViewDataColumn Header="Col2" DataMemberBinding="{Binding Col2}" IsGroupable="False" IsFilterable="True" ShowDistinctFilters="False" IsVisible="{Binding ElementName=chk2, Path=IsChecked}" />
</telerik:RadGridView.Columns> </telerik:RadGridView>
In the above example, checking and unchecking chk1 will show and hide column 1 in the grid. Checking and unchecking chk2 does nothing.
Posted 24 Jan 2012 Link to this post
Here is an example how to achieve your goal:
<
Grid
x:Name
=
"LayoutRoot"
Background
"White"
>
Grid.RowDefinitions
RowDefinition
Height
"Auto"
/>
</
StackPanel
CheckBox
"chk1"
IsChecked
"{Binding Columns[\Col1\].IsVisible, ElementName=RadGridView1, Mode=TwoWay}"
"chk2"
"{Binding Columns[\Col2\].IsVisible, ElementName=RadGridView1, Mode=TwoWay}"
telerik:RadGridView
"RadGridView1"
CanUserFreezeColumns
"False"
ItemsSource
"{Binding}"
AutoGenerateColumns
telerik:StyleManager.Theme
"Windows7"
EditTriggers
"CellClick"
Grid.Row
"1"
telerik:RadGridView.Columns
telerik:GridViewDataColumn
Header
"Col1"
DataMemberBinding
"{Binding Col1}"
IsGroupable
UniqueName
IsFilterable
"True"
ShowDistinctFilters
"Col2"
"{Binding Col2}"
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>