Reputation: 103
I have a Telerik GridView. My GridView has several columns in it. The first column is a checkbox, and when I check or uncheck it, it changes a property in my Model named IsSelected!
The part of my code looks like this one:
<telerik:RadGridView>
<telerik:RadGridView.Columns>
<telerik:GridViewColumn Header=""
IsFilterable="False"
IsSortable="False"
IsReadOnly="True"
HeaderCellStyle="{StaticResource GridViewDefaultCheckboxStyles}">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}"
Style="{StaticResource GridCheckBoxStyle}">
</CheckBox>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>
<!--Other columns-->
</telerik:RadGridView.Columns>
</telerik:RadGridView>
Now I want to remove the checkbox, and when I click a row in my grid(anywhere in the row), I want the IsSelected property to change its value. How can I achieve that? I mean when I click a row, the selected row should be bound somehow to my IsSelected property, without braking the MVVM pattern.
Upvotes: 0
Views: 1548
Reputation: 5554
Consider adding a custom behavior to the GridView that listens to the selection changed event, and updates the IsSelected item. This should keep your design clean.
Upvotes: 2