WPF win8平板电脑模式键盘隐藏屏幕底部的项目

WPF win8 tablet mode the keyboard hide the item on the bottom of the screen

我目前正在使用WPFWIN8table模式设计一些软件。

有些地方需要使用文本框输入一些数字

我用了一些方法终于显示了键盘:http://brianlagunas.com/showing-windows-8-touch-keyboard-wpf/

但我发现,有时键盘出现后会覆盖底部或中间的某些项目

例如:我在屏幕上有 5 个文本框

<Grid>
  <TextBox HorizontalAlignment="Left" Margin="500,95,0,0"  Height="23" Width="120"/>
  <TextBox HorizontalAlignment="Left" Margin="500,295,0,0"  Height="23" Width="120"/>
  <TextBox HorizontalAlignment="Left" Margin="500,495,0,0"  Height="23" Width="120"/>
  <TextBox HorizontalAlignment="Left" Margin="500,695,0,0"  Height="23" Width="120"/>
  <TextBox HorizontalAlignment="Left" Margin="500,800,0,0"  Height="23" Width="120"/>
</Grid>

但现在我发现如果键盘将焦点放在某些不在顶部的文本框上,可能在中间或底部。键盘将覆盖它。 我什至看不到我输入的内容。(如图所示)

请问有什么好的方法可以解决吗?谢谢。

PS: 我尝试过拖动键盘,但看起来这不是一个好的解决方案, 因为一些文本框在中间,键盘仍然会覆盖中间的文本框

用户可以移动键盘,使其不被遮挡。最好让用户以这种方式处理这种情况,而不是尝试重新设计 Windows 体验

要做到这一点,您必须做类似的事情。

1) 您的视图必须是可滚动的(在滚动查看器内)

2) textbox.BringIntoView() 通常可以工作,但是使用您当前使用的解决方案..这是不可能的,因为键盘显示是在 textbox.BringIntoView() 之后调用的.. .

在这个帖子中查看我的 post Show & hiding the Windows 8 on screen keyboard from WPF

它是 showing/hiding win 8 键盘和文本框聚焦时自动聚焦的完整实现,并且保留了使用 inkDisableHelper 时失去的所有 wpf 触摸功能

当键盘为 displayed.Microsoft 表示此行为是自动的但可以用 EnsuredFocusedElementInView(example here)

我认为这可以通过调整Y过渡来解决

     _offSet = 0;

        Windows.UI.ViewManagement.InputPane.GetForCurrentView().Showing += (s, args) =>
        {
            _offSet = (int)args.OccludedRect.Height;
            args.EnsuredFocusedElementInView = true;
            var trans = new TranslateTransform();
            trans.Y = -_offSet;
            this.RenderTransform = trans;
        };

        Windows.UI.ViewManagement.InputPane.GetForCurrentView().Hiding += (s, args) =>
        {
            var trans = new TranslateTransform();
            trans.Y = 0;
            this.RenderTransform = trans;
            args.EnsuredFocusedElementInView = false;
        };

构造函数内部。

你也可以看看

1)Tips and Tricks for C# Metro developers: Handling the virtual keyboard

2)Popup stays under virtual keyboard in stead of scrolling up with the bottom appbar