When DoubleEditBox has keyboard focus, MaskedTextBox is returned as focused element

Editors for WPF Forum

Posted 10 years ago by Vinay Chougule
Version: 14.1.0601

I have a DoubleEditBox in a view. In our product I can edit the doubleEditBox and do an operation (e.g. click on another tab) such that the doubleEditBox is removed from the view. Because the binding is on LostFocus, when i come back to the view, the value is lost.

Our solution which does not work:
Before the view is removed, we are trying to update the ViewModel this way (the code is called from a service):

var focusedElementDoubleEditBox = FocusManager.GetFocusedElement(Application.Current.MainWindow) as FrameworkElement;

var expression = focusedElementDoubleEditBox.GetBindingExpression(DoubleEditBox.ValueProperty)

The problem is
1. Focused Element is not DoubleEditBox but it is MaskedTextBox.
2. If I use MaskedTextBox and get DoubleEditBox, DoubleEditBox does not have the edited value.

If I use a TextBox instead of a DoubleEditBox, everything works nicely.
How do i get the above stuff working for DoubleEditBox?

We are using a lot of Actipro editors and we are facing the same problem with many.

Thank you,

Kind Regards,


Comments (2)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Vinay,

Right, the element that has focus should be a MaskedTextBox since that comes from the Part's template.  The easiest way to force the binding update would be the move focus out of control prior to it changing.  You could detect this by watching for focus in the MaskedTextBox when a tab change is about to occur then perhaps move focus to some dummy control or to the new tab itself.  I would think that would force the binding to update.  It's probably easiest to go the focus move route since edit boxes have several levels of bindings (edit box / part group / part / masked text box) that drive the control.

Actipro Software Support

Posted 10 years ago by Vinay Chougule

This works,

Thanks a lot,

Kind Regards,


The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.