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.
Hi Sundar,
I am posting the response from our developers. They reviewed your sample and your question concerning the editor's behavior when defining the CellValuePresenter using our editors with the UpdateSourceTrigger property set to LostFocus. It may be helpful to others with the same experience.
By setting the ContentTemplate this way our data error template triggers interfere when coming out of edit mode. A workaround is to set the FieldSettings.SupportDataErrorInfo to false on the affected fields, e.g.
<Custom:FieldSettings SupportDataErrorInfo="False" CellValuePresenterStyle="{StaticResource CVPValue1}"/>
Note: There is a better way to accomplish what you are trying to do by using a custom editor instead, which would leverage all of our editor infrastructure. Andrew Smith has a blog post with a sample here.
http://ko.infragistics.com/community/blogs/andrew_smith/archive/2009/03/27/hosting-wpf-controls-in-a-xamdatagrid-cell.aspx
I've been working with your sample and I see the same behavior. I am submitting your issue to development and I have opened a case for you, CAS-131952-S3Z4Y8. for purposes of tracking the issue.
You will hear from me shortly thru the case.