代码之家  ›  专栏  ›  技术社区  ›  qakmak

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

  •  6
  • qakmak  · 技术社区  · 10 年前

    我当前正在使用 工作压力系数 WIN8表格模式 设计一些软件。

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

    我使用某种方式最终显示键盘: 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>
    

    但现在我发现,如果键盘关注的是某个文本框,而不是顶部,可能是中间,也可能是底部。键盘将覆盖它。 我甚至看不清我在输入什么 。(喜欢图片)

    enter image description here

    那么有什么好的方法来解决它吗?非常感谢。

    PS(秒): 我试图拖动键盘,但看起来这不是一个好的解决方案, 因为一些文本框 在中间 ,键盘仍将覆盖中间的文本框。

    3 回复  |  直到 10 年前
        1
  •  3
  •   Community CDub    8 年前

    为了实现这一点,你必须做类似的事情。

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

    2) 文本框。BringIntoView()通常可以工作,但对于您正在使用的当前解决方案,这是不可能的,因为键盘显示是在文本框之后调用的。BringInto View()。。。

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

    这是一个完整的实现,可以在文本框聚焦时显示/隐藏win 8键盘和自动聚焦,并保留使用inkDisableHelper时丢失的所有wpf触摸功能

        2
  •  3
  •   Glen Thomas    10 年前

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

        3
  •  0
  •   Rohit    10 年前

    虚拟键盘应该在显示键盘时自动将聚焦的文本框移动到视图中。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

    推荐文章