Windows Phone键盘逗号-点冲突 [英] Windows Phone keyboard comma - dot conflict
问题描述
我想使用数字键盘(InputScope=Number
),但想显示','而不是'.'.在左下角,因为它是土耳其语的小数点分隔符.
即使我在以下代码中强制使用区域性",键盘布局也会根据电话语言而显示:
System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("tr-TR");
System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("tr-TR");
I would like to use Numeric keyboard (InputScope=Number
) but want to display ',' instead of '.' on the lower-left hand corner because it is the decimal separator in Turkish language.
The keyboard layout appears depending on the phone language even if I force the Culture in code like this:
System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("tr-TR");
System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("tr-TR");
如何强制数字键盘的左下角只有','?
How can I force numeric keyboard with only ',' on the lower-left hand corner?
或者至少我该如何检测KeyEventArgs上两个字符之间的差异?因为两者都返回Unknown as Key code(很明显是相同的键),并且当用户按下时我无法想出一种区分它们的方法?
Or at least how can I detect the difference between the two characters on KeyEventArgs? Because both returns Unknown as Key code (well obviously same key) and I cannot come up with a way to differentiate them when user presses?
推荐答案
鉴于您无法更改键盘的区域性,您有两个选择:
Given that you can't change the culture for the Keyboard you have two options:
- 挂钩KeyUp,如果KeyCode不知道,则您将得到.或,
- 钩上TextChanged并检查最后一个字母是否为.或,并根据需要进行替换(请注意,如果您更新TextChanged中的文本,则将重新触发TextChanged)
例如:
private void txt_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == System.Windows.Input.Key.Unknown)
{
txt.Text = txt.Text.Replace('.', ',');
// reset cursor position to the end of the text (replacing the text will place
// the cursor at the start)
txt.Select(txt.Text.Length, 0);
}
}
这篇关于Windows Phone键盘逗号-点冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!