WPF toolkit datagrid with checkbox and radiobutton in each row

Aug 11, 2009 at 6:44 PM


    I have two scenarios. For the first scenario, I need to display a datagrid with a set of columns and rows. Each row must have a checkbox associated with it so that users can select multiple rows.

    In the second scenario, I will have to display a set of rows and columns. Each row should have a radio button associated with it so that users can select only one row at a time.

   How can I get this done using the wpf toolkit datagrid. Also, it would be great if there is an example of how to do this using the MVVM model.




Aug 12, 2009 at 7:16 AM

Adjusting the RowHeaderTemplate and setting SelectionMode appropriately should allow you to do what you want.

Colin Eberhardt has a good write-up on this at http://www.scottlogic.co.uk/blog/wpf/2008/11/multiselect-datagrid-with-checkboxes/. It deals with multiple selections with checkboxes, but the exact same principle should apply just as well to radiobuttons and single item selection mode.