Hi!
I'm trying to create a xamDataGrid with a couple of read-only string columns and a dynamic number of checkbox columns. I also want to be able to select multiple checkbox cells and edit them all simultaneously e.g. by pressing spacebar or something. At the moment I am able to create the string and checkbox columns by setting the DataSource to a DataTable created in the ViewModel. I have to set typeof(string) and typeof(bool) for the DataColumns. The problem now is that I no longer have a reference to the underlying object in the xamDataGrid. It only has string/bool values. I have one object per checkbox cell, not one object per row. The string columns are special fixed columns.
How can I create a dynamic number of rows/columns with checkbox cells bound to a bool property on my objects, one object per checkbox cell. Do I have to use events and override the FieldLayout stuff? I also need multiselection of checkbox cells to be able to check/un-check all selected checkboxes.
- Atle
Hello Atle,
Thank you for your feedback. I am glad that you have managed to solve your issue.
I dropped the checkbox columns. I am instead writing some text and changing colors of the cells according to their data state. Editing I do through multi select behavior of cells and inserting the objects in the selectedcells into another view/viewmodel with property editors.
I am just checking if you require any further assistance on the matter.
You can try to set the unbound field in code behind as described in the following link :
http://help.infragistics.com/NetAdvantage/WPF/2013.1/CLR4.0/?page=xamDataPresenter_Define_a_Field_Layout.html
The functionality that you would like to have cannot be achieved without unbound field.
Let me know, if you need any further assistance on this matter.
Thanks for the sample, however, I cannot add fields in xaml, since I do not know how many rows OR columns that the grid will have before runtime. The xamDataGrid's data source is a DataTable property on my ViewModel (this could be changed I guess). The DataTable has one object per cell, not one object per row. These objects have an IsChecked property which I would like to bind to. But, since I cannot add a dynamic number of columns in Xaml, how do I set up a binding to a property on the cell's object? AutoGenerateColumns is true by the way.