简体   繁体   English

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

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

I'm currently use WPF and WIN8 table mode design some software. 我目前正在使用WPFWIN8表模式设计一些软件。

There is some place need input some number use Textbox . 有些地方需要输入一些数字使用Textbox

I use some way to finally show the Keyboard: http://brianlagunas.com/showing-windows-8-touch-keyboard-wpf/ 我用某种方式最终显示键盘: http//brianlagunas.com/showing-windows-8-touch-keyboard-wpf/

But I found, sometimes the Keyboard will cover some item on the bottom or middle after it show up. 但是我发现,有时键盘会在它出现后覆盖底部或中间的某些项目

For example: I have 5 Textbox on the screen 例如:我在屏幕上有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>

But now I found if the Keyboard get focus on some Textbox not on the top, Maybe on the middle or maybe on the bottom. 但现在我发现键盘是否专注于某些不在顶部的文本框,可能在中间或者可能在底部。 The Keyboard will cover it. 键盘将覆盖它。 I even can't see what I am typing in .(Like the Picture) 我甚至看不到我在输入的内容 。(如图片所示)

在此输入图像描述

So Is there any good way to fix it ? 那么有什么好方法可以解决它吗? Thank you. 谢谢。

PS: I've try to drag the Keyboard, but Looks like it's not a good solution, because some Textbox on the middle , Keyboard will still cover which Textbox on the middle. PS:我试图拖动键盘,但看起来它不是一个好的解决方案,因为中间的一些文本框,键盘仍将覆盖中间的哪个文本框。

The keyboard can be moved used by the user so that it is not covering. 键盘可以被用户移动使用,以便它不会覆盖。 Its best to let the user handle the situation this way than try to re-engineer the Windows experience 最好让用户以这种方式处理这种情况,而不是尝试重新设计Windows体验

to make this possible you have to do something similar to this. 为了使这成为可能,你必须做类似的事情。

1) your view must be scrollable (inside a scrollviewer) 1)您的视图必须可滚动(在滚动查看器内)

2) textbox.BringIntoView() would normally work, but with the current solution you are using.. it won't be possible because the keyboard show is called after textbox.BringIntoView()... 2)textbox.BringIntoView()通常会工作,但是使用当前的解决方案..这是不可能的,因为键盘节目是在textbox.BringIntoView()之后调用的...

See my post in this thread Show & hiding the Windows 8 on screen keyboard from WPF 在此主题中查看我的帖子在WPF中显示和隐藏Windows 8屏幕键盘

It's a complete implementation of showing/hiding the win 8 keyboard and auto focus when the textbox is focused and you keep all the wpf touch functionality that you lose when you are using inkDisableHelper 这是一个完整的实现,在文本框聚焦时显示/隐藏win 8键盘和自动对焦,并保留使用inkDisableHelper时丢失的所有wpf触摸功能

The virtual keyboard is supposed to automatically move the focused TextBox into view when the keyboard is displayed.Microsoft says this behavior is automatic but can be overridden with EnsuredFocusedElementInView ( example here ) 当键盘显示时,虚拟键盘应该自动将聚焦的TextBox移动到视图中EnsuredFocusedElementInView说这种行为是自动的,但可以用EnsuredFocusedElementInView覆盖( 这里的例子

I think this can be solved by adjusting the Y transition 我认为这可以通过调整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;
        };

inside the constructor. 在构造函数内部。

Also you can take a look at 你也可以看看

1) Tips and Tricks for C# Metro developers: Handling the virtual keyboard 1) C#Metro开发人员的提示和技巧:处理虚拟键盘

2) Popup stays under virtual keyboard in stead of scrolling up with the bottom appbar 2) 弹出窗口停留在虚拟键盘下,而不是使用底部应用栏向上滚动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM