Thursday, May 21, 2015

[XAML] to switch the IME (kana-kanji conversion) in WPF (and to WPF from Windows Forms)

[XAML] to switch the IME (kana-kanji conversion) in WPF (and to WPF from Windows Forms)

 Author: Masahisa Ohno
Verification environment: Visual Studio 2008, Visual Studio 2010
Updated: November 26, 2010
  The TextBox of WPF does not have an ImeMode property like Windows Form. Instead use the attached property of InputMethod.

ポイント

Windows フォームでは、IME (かな漢字変換) を制御するためにコントロールごとに ImeMode というプロパティが用意されていましたが、WPF では IME のような入力方法を制御するために InputMethod というクラスが用意されています。たとえば、現在の IME の状態を取得したり、設定したりするためには InputMethod.Current (現在アクティブな入力方法) の ImeState というプロパティを使います。
また、入力用のコントロールでは、添付プロパティを使って、コントロールにおける IME の状態を指定できます。Windows フォームの ImeMode プロパティの値に相当する設定を以下に示します。

[XAML] WPF で IME (かな漢字変換) を切り替えるには (Windows フォームから WPF へ)

No comments: