Geeks With Blogs


View Anthony Trudeau's profile on LinkedIn

Add to Technorati Favorites

Anthony Trudeau

The Telerik RadGridView for WPF is a flexible visual control for displaying and manipulating tables of data. It’s not without it’s quirks though. I ran into one of those quirks recently.

The behavior of the RadGridView requires that you first activate the cell for editing. That enables the editing controls underneath. Although that provides better editing capabilities, it also can be unintuitive. In my case I don’t want my users to have to click a checkbox value twice in order to change the value.

This can be solved easily by setting the EditTriggers and AutoSelectOnEdit properties to CellClick and True respectively. Unfortunately, the story doesn’t end there. You would think you could set those properties in a style with a TargetType of GridViewCheckBoxColumn. You’d be wrong.

<!-- This works -->
<telerik:GridViewCheckBoxColumn Header="Flag #1"
      DataMemberBinding="{Binding Flag1}"
      EditTriggers="CellClick" AutoSelectOnEdit="True"/>

<!-- This doesn’t work -->
<Style TargetType="{x:Type telerik:GridViewCheckBoxColumn}">
      <Setter Property="EditTriggers" Value="CellClick" />
      <Setter Property="AutoSelectOnEdit" Value="True" />

Telerik told me that is the correct, expected behavior, because the columns in the RadGridView are not visual elements. Their explanation is that the Style property comes from the base class FrameworkContentElement, but the column objects aren’t visual elements. That may be an implementation truth, but that doesn’t make the behavior correct or expected.

It’s unintuitive that the GridViewCheckBoxColumn exposes a Style property that cannot be used properly, but there it is. At least there’s a way to get the desired effect.

Posted on Thursday, June 5, 2014 9:55 PM | Back to top

Comments on this post: Single-Click Checkbox in RadGridView

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Anthony Trudeau | Powered by: