Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Property setter not called from the controls in the DataTemplate with UpdateSourceTrigger set to LostFocus.
posted

Hi,

We are trying to show different controls in the XamDataGrid based on the datatype specified as part of the datasource.  For this we are using CellValuePresenterStyle.  In the CellValuePresenterStyle used DataTrigger to verify the value present in the datatype property and based on that we show either XamNumericEditor or a XamTextEditor.  This part is working fine as long as the UpdateSourceTrigger is set to PROPERTYCHANGED.  If we set the UpdateSourceTrigger to LOSTFOCUS then the property setter is not firing when we leave the textbox.  Because of this the new value entered in the grid is replaced with the old value as soon as we tab out of the cell.  In our application we usually save the data to the database when focus leaves out of the control.  We do not want to save the data as we type. 

We have created a sample application to simulate this scenario and attached here.  In the sample application, We have 5 properties.  Description (First property in the datasource) is not editable from the grid.  Value1 (Second property) and Value2 (Fourth property) are editable in the grid.  Based on the values in the Datatype property (DataType1 and DataType2 - Third and Fifth property) the grid will show either numeric editor or text editor for Value1 and Value2 columns.  Value1 property uses lost focus as the UpdateSourceTrigger and Value2 property uses propertychange as the UpdateSourceTrigger.  If we edit Value1 column and tab out of the field in the grid then the Value1 property setter is NOT called.  This happens for both numeric editor and text editor.  Whereas if we edit Value2 column, as we type, the Value2 property setter is called.  In our case we need the Value1 property setter to be called when we tab out of the field.  Please let us know how can we make the Value1 property setter to be called when the user tabs out of the Value1 field.

Thanks & Regards,

Sundar.

TestCVP.zip