I have existing infragistics ASP.Net code as follows
UltraWebGrid1.Columns.Add(
"ALL", "ALL")
UltraWebGrid1.Columns(0).Type = ColumnType.CheckBox
can any one help me out this code equivalent for WPF XamDataGrid for adding column with check boxes as first column
and also records should get selected in xamdatagrid when I check those check boxes
Thanks in advance.
To add the Unbound field you can use this code:
Dim checkBoxField As New UnboundField() checkBoxField.DataType = GetType([Boolean]) checkBoxField.Name = "CheckBoxField" XamDataGrid1.FieldLayouts(0).Fields.Insert(0, checkBoxField)
Remember that the FieldLayout object is essentially equivalent to the 'Band' object in the WebGrid.
As far as synchronizing the checkbox to the selection of the record, you can search the forums for more information, but I will give you the theoretical overview for what you need to accomplish. You will have to include an IsSelected property with your business object of the business object's ViewModel (or equivalent). This property will have to implement the changed notification via the INotifyPropertyChanged interface.
You would create a CellValuePresenter Style for your UnboundField and you would create a RecordPresenter Style. In the CellValuePresenter Style, you would bind the cell's value to your business object's IsSelected property and you would bind the RecordPresenter's IsSelected property to your business objects property as well.
The reason you need to create the property is because the record's IsSelected property will provide change notification. Hope this information helps.
Hi Aaron,
Can you please post code for this part of the solution? I am stuck in that.
"You would create a CellValuePresenter Style for your UnboundField and you would create a RecordPresenter Style. In the CellValuePresenter Style, you would bind the cell's value to your business object's IsSelected property and you would bind the RecordPresenter's IsSelected property to your business objects property as well."
Thanks!!
Thanks Aaron, Adding a checkbox worked. and thanks for suggestion.