我想更改Textbox.GotFocus
和Textbox.LostFocus
上的InputLanguage,所以我这样做:
<Style TargetType="{x:Type TextBox}" x:Key="EnglishTextStyle">
<Style.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="InputLanguageManager.InputLanguage" Value="en-us" />
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="False">
<Setter Property="InputLanguageManager.InputLanguage" Value="fa-ir" />
</Trigger>
</Style.Triggers>
</Style>
它会将InputLanguage切换为
en-us
,但不会将其返回给fa-ir
,这是什么问题? 最佳答案
您还需要指定类型:
<Trigger Property="TextBox.IsKeyboardFocusWithin" Value="False">
<Setter Property="TextBox.InputLanguageManager.InputLanguage" Value="fa-ir" />
</Trigger>