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
95
Control loses property values on LostFocus in XamDataGrid
posted

Hi,

I am creating XamDataGrid with all the columns being dynamically generated using control templates.

I am facing one problem while doing some operation on LostFocus of the Control. The scenario is explained as follows -

I have derived XamMaskedEditor and created a custom control of it - MyXamMaskedEditor.

I am using this control in grid and non grid mode. For that I am creating a ControlTemplate of it and setting it as EditorStyle of the XamDataGrid Field when switching to grid mode.

My requirement is that on the lost focus of MyXamMaskedEditor  I have to update values in another control on the form. For that I set values in underlying binding source which in turn raised property changed event and updates the control which is bound to that particular property which I am updating. This works fine in non grid mode.

But when I switch to grid mode then on the LostFocus (actually I am overriding OnIsFocusWithinChanged method)  this thing breaks !!!!

How? When I debugged then I found that this control (MyXamMaskedEditor) loses all the property values when the execution is within OnIsFocusWithinChanged method. For instance when you see control Name it is blank "" and similarly all other properties are blank!! . But it is required for me to get access to these property values so that I can perform desired action based on those values.

And this thing is applicable to all the controls and not specifically to infragistics one like TextBox, ComboBox etc.

When I debugged then I found that on EditModeEnding the values of control are intact but in EditModeEnded or LostFocus these values are lost. The events are fired in following sequence -

EditModeEnding (in XamDataGrid)

OnIsFocusWithinChanged (in Control)

EditModeEnded (in XamDataGrid)

I can debug OnIsFocusWithinChanged method override and can see there is no values to its properties.

Now my question is that if control is not destroyed when OnIsFocusWithinChanged  is called then why the property values are destroyed??

Any help in this regard will help me a lot.

Thanks,