C# Windows 8 在存在组合框时隐藏键盘

本文关键字:隐藏 键盘 组合 存在 Windows | 更新日期: 2023-09-27 18:32:19

我想在Windows 8应用程序中隐藏虚拟键盘。我知道如果将焦点设置在按钮上,它会隐藏,但我的问题是,如果我这样做,那么文本框下方的组合框将被冻结并且无法打开。我的代码:

<Grid Tapped="Grid_Tapped">
<Grid.RowDefinitions>
    <RowDefinition Height="auto"></RowDefinition>
    <RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>  
<TextBox Margin="12,12,12,12"  Grid.Row="0" VerticalAlignment="Center"
                     Name="aksiografo_textbox"
                     Text="{Binding ChequeNumber, Mode=TwoWay}" />
<ComboBox
Name="BankListPicker"
Grid.Row="1"
Margin="12,12,12,12" 
SelectedItem="{Binding Bank, Mode=TwoWay}"                        
ItemTemplate="{StaticResource LiPickerTemplate}" />
</Grid
private void Grid_Tapped(object sender, TappedRoutedEventArgs e)
{            
    ok_button.Focus(Windows.UI.Xaml.FocusState.Pointer);
}

C# Windows 8 在存在组合框时隐藏键盘

我解决了。问题确实是窃听事件。我创建了一个布尔组合=false;

private void combo_tapped(object sender, TappedRoutedEventArgs e)
{
    combotapped = true;
}
private void Grid_Tapped(object sender, TappedRoutedEventArgs e)
{
   if (combotapped == false)
   ok_button.Focus(Windows.UI.Xaml.FocusState.Pointer);
   combotapped = false;
}