2013-06-11 63 views
1

我想使用數字鍵盤(InputScope=Number),但想顯示','而不是'。'。在左下角,因爲它是土耳其語中的小數點。 System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("tr-TR"); System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("tr-TR");Windows Phone鍵盤逗號 - 點衝突

如何強制數字鍵盤,只有「」上,在下左下角: 鍵盤佈局取決於即使我力的文化在這樣的代碼手機語言出現?

或者至少我該如何檢測KeyEventArgs上兩個字符之間的差異?因爲兩者都將「未知」作爲關鍵代碼返回(非常明顯,同樣的關鍵),並且當用戶按下時我無法想出區分它們的方法嗎?

回答

0

既然你無法改變鍵盤的文化,你有兩個選擇:

  1. 掛鉤KEYUP如果邀請碼是未知的,然後你得到來尋。或者,
  2. Hook 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); 
     } 
    } 
1

這實際上是手機本身的設置。當區域設置爲逗號分隔符和鍵盤的區域時,將顯示逗號。請參閱以下屏幕截圖:法國地區和法國鍵盤

enter image description here