TextBox で IME を ON にする
こんばんは、siokoshou です。好きなものはコーヒーです。
TextBox で IME を ON にするには、<TextBox InputMethod.PreferredImeState="On" /> のように書けば OK です。しかし、WinForm では特定のコントロール上では ON、ほかでは元のままとすることができたけど、この方法ではいったん ON になると後はどこでもずーっと ON です……。同様のことがしたければ、GotFocus/LostFocus で InputMethod.SetPreferredImeState( textbox, InputMethodState.On ); のように書くことで制御するしかないようです。
では、サンプル。
<Window x:Class="ImeTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="150" Width="300"> <UniformGrid Columns="2"> <Label Target="{Binding ElementName=DoNotCare}">IME _DoNotCare</Label> <TextBox Name="DoNotCare" InputMethod.PreferredImeState="DoNotCare" /> <Label Target="{Binding ElementName=On}">IME O_N</Label> <TextBox Name="On" InputMethod.PreferredImeState="On" /> <Label Target="{Binding ElementName=Off}">IME O_FF</Label> <TextBox Name="Off" InputMethod.PreferredImeState="Off" /> <Label Target="{Binding ElementName=Combo}">_ComboBox</Label> <ComboBox Name="Combo" IsEditable="True" GotFocus="Combo_GotFocus" /> </UniformGrid> </Window>
WPF + IME といえば、この話題にも注目です。 http://forums.microsoft.com/MSDN-JA/ShowPost.aspx?PostID=1497209&SiteID=7