Hi,
I am adding UnboundFields onto my XamDataGrid from code, and setting the binding in code as per below:
UnboundField unboundField = new UnboundField() { Name = "MyFieldName", BindingRetentionMode = BindingRetentionMode.AutoRelease, Binding = new Binding() { Path = new PropertyPath("MyPropertyPath"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, NotifyOnValidationError = true, ValidatesOnDataErrors = true } }; FieldSettings fieldSettings = new FieldSettings() { EditAsType = typeof(string),
}; unboundField.Settings = fieldSettings; defaultFieldLayout.Fields.Add(unboundField);
As you can see, i have set the UpdateSourceTrigger to "PropertyChanged". However, when I edit one of the values in the cells on the XamDataGrid, my bound property (on my viewmodel) does not update until I leave the cell. So, essentially, the UpdateSourceTrigger being exhibited is "LostFocus", even when i have set it to "PropertyChanged".
Can anyone please suggest why this is the case?
Thanks,
Phil
Thanks Stefan - thats helpful.
Hello Phil,
You are right that the versions where this Property is available doesn't support .NET 3.5. Also there isn't such event as the one you described, but there is another workaround you can use. You can create a Style like this for the XamTextEditor:
<Style TargetType="{x:Type igEditors:XamTextEditor}"> <Setter Property="Text" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}, Path=Value, UpdateSourceTrigger=PropertyChanged}" /> </Style>
which is the editor used by default in the UnboundField. This way the source will update on PropertyChanged, If you set the UnboundField's DataType, you should create a similar Style for the Editor that will be used, XamNumericEditor for double and integer and etc. Please let me know if this helps you or you have further questions on this matter.
Looking forward for your reply.
Hi -
Just revisiting this. Unfortunately, I am constrained to using .net 3.5. So i dont think there is a version of Infragistics available to me which contains the DatItemUpdateTrigger. Am i right ?
One of the ways that I though I might be able to set the UpdateSourceTrigger as required, would be if there were an event which gets raised when the binding on the cell gets created. Does such an event exist?
The binding being defined is not the binding used by the element used for editing - it is the binding used by the grid to get/set the value of the Cell. The Value of the Cell is not updated during edit mode by default. If you want that behavior then you can use the DataItemUpdateTrigger property that was recently added to the FieldSettings class. It is available in 13.2 as well as the latest SR's for 12.2 and 13.1.