Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
285
Selecting checkbox on first click
posted

I have a checkbox column in the grid and when clicking on the checkboxes in different rows, I need to click once for the row/cell to go into edit mode, and once again to change the state of the checkbox. This is obviously a huge usability fail but I can't seem to get around it.

In part, the reason I haven't found a solution yet is that all cells are created in a custom TemplateSelector using XamlReader, which prevents me from defining events as that is not accepted by the XamlReader. I have managed to use a combination of CellEnteredEditMode and MouseLeftButtonUp on the grid itself but that only works for when I click on the cell area around the checkbox itself. I imagine I would have to do something similar for the checkbox object in order to really make it work, but as I mention, I can't add events to strings passed to XamlReader.

A complete test project can be downloaded here: http://www.sendspace.com/file/16nw5w. If you run it, the first column will be a checkbox column and clicking outside the checkbox, but within a cell in a row which is not active will change the state of the checkbox. I want the same behaviour when clicking on the checkbox too.

Thanks

  • 40030
    Offline posted

    Hi, 

    Is your checkbox bound to anything? If not, we actually recommend, if possible, to have the checkbox bound to your viewModel, so that you don't need to listen to events. 

    However, if thats not possible, and you're using a TemplateColumn then i suppose you use the CellControlAttached event, and attach your Checked and Unchecked events then.  Note: as CellControls are recycled, you'll need to make sure you remove the events before you add them, to avoid attaching multiple event handlers. 

    Another options is to create a custom Column. Which will give you more granular control and allow you to create the checkbox in code and hook up the event. 

    A colleague of mine wrote a very good article on how to create a custom column in the xamGrid:
    https://es.infragistics.com/community/blogs/b/devin_rader/posts/creating-custom-columns-for-xamgrid

    Hope this helps,

    -SteveZ