DoubleEditBox does not handle comma as dot when changing the language

Editors for WPF Forum

Posted 6 months ago by Daniel Constantin - ModuleWorks GmbH
Version: 19.1.0687
Avatar

Hi,

When my Windows language is English - US I can add numbers with decimals from the numpad. If I change to other languages that number, eg: "12.34" becomes "12,34" and is stored as "1234" which is wrong.

How can I make that the comma to be treated as dot ? Or to force somehow the culture of the DoubleEditBox to be English US always

Kind regards,

Dani

Comments (4)

Answer - Posted 6 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

This seems to be a bit of a shortcoming in the WPF TextBox control and I think this thread is related.  The DoubleEditBox uses a regular TextBox in its template and it seems to always insert a "." (dot) when the numpad decimal character is typed, at least on an English keyboard.

DoubleEditBox will use the number settings from CultureInfo.CurrentCulture.  Per that thread, I think the workaround is to find the nested TextBox in DoubleEditBox and attach to its PreviewKeyDown event.  Then manually insert a comma if appropriate for that key.

Would that sort of logic resolve the issue for you?

[Modified 6 months ago]


Actipro Software Support

Posted 6 months ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Hi,

How can I find that nested TextBox and connect to that event. I cannot connect to it because it is inside a style.

Kins regards,

Daniel

Posted 6 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

Sorry the link in the previous post wasn't submitted properly.  It's fixed now.

This kind of code in a DoubleEditBox-inherited class would get the TextBox:

public override void OnApplyTemplate() {
	base.OnApplyTemplate();

	var textBox = this.GetTemplateChild("PART_TextBox") as System.Windows.Controls.TextBox;
	if (textBox != null) {
		// Add logic such as in previously-linked thread
	}
}


Actipro Software Support

Posted 6 months ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Hi,

I have a solution searching that nested control using the VisualTreeHelper as I do not make it work connecting directly to that event.

Kind regards,

Daniel

The latest build of this product (v21.1.3) was released 9 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.