I have a XamDataGrid where one column is an UnboundField bound to a value from an array, it is setup to edit as a decimal value, most of the setup is:
field.DataType = typeof(object);
field.BindingPath = new PropertyPath("Cells[" + index + "].Value");
field.Settings.CellValuePresenterStyle = Global.Instance.Cache.GetCellValuePresenterStyle(index);
field.Settings.EditAsType = typeof(decimal);
field.Settings.SortComparer = new DecimalSorter();
string numberFormat = "-nnn,nnn,nnn,nnn,nnn";
if (_precision > 0)
numberFormat += "." + new string('n', _precision);
Style editStyle = new Style(typeof(XamNumericEditor));
editStyle.Setters.Add(new Setter(XamNumericEditor.MaskProperty, numberFormat));
field.Settings.EditorType = typeof(XamNumericEditor);
field.Settings.EditorStyle = editStyle;
field.Converter = new DecimalConverter();
Normally I can change the value that the cell is bound to and call NotifyPropertyChanged("Value") on the object and it updates everything just fine, the problem comes when I have just edited a value in a cell by typing in a new number and hitting enter, then some external UI changes the value that should be held in that cell. Every other cell in the grid updates fine, but the one I was just editing ignores the NotifyPropertyChanged and doesn't update at all, if you scroll that row off the screen and then back again it will then display the new value correctly.
It seems like because that cell was just being edited the NumericEditor is storing a value and not getting notified of the NotifyPropertyChanged call, how can I force the cell to update without telling the user to scroll down and then back up again?
I was able to come up with the following workaround, before I was doing:
if (needRefresh[columnNumb])
currentIntervalBinder.CallNotifyValueChanged(columnNumb);
Which called NotifyPropertyChanged("Value") on what that column is bound to for every cell, this worked UNLESS you were just editing a cell, in which case it ignored the change in value until you scrolled that row off the screen and back again.
My workaround is to manually set the CellValuePresenter value by doing:
{
foreach (DataRecord record in DataGrid.Records)
CellValuePresenter present = CellValuePresenter.FromRecordAndField(record, DataGrid.FieldLayouts[0].Fields[columnNumb]);
if (present != null && present.Editor != null)
object value = ((RowData)record.DataItem).Cells[columnNumb].Value;
if (!value.Equals(present.Value))
present.Value = value;
}
Thank you for posting your work-around. I apologize that someone from infragistics did not get back to you right away last year. We experienced a large mass of posts and have been adding people over the last few months to ensure we can hahdle the volume of posts that our forums receive.
Concerning your issue, when it comes to Unbound Fields to custom data sources, sometimes it is necessary to implement an alternative updating scheme. I appreciate you posting your solution!
Thank you,