当 Surface 键盘显示在 Windows 8 商店应用程序中时,弹出窗口不会向上移动 [英] Popup windows doesn't move up when Surface keyboard is shown in Windows 8 store app

查看:25
本文介绍了当 Surface 键盘显示在 Windows 8 商店应用程序中时,弹出窗口不会向上移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Windows 商店应用程序,它要求用户通过大量文本框输入数据.

I have a windows store application that requires the users to enter data via numerous textboxes.

当屏幕底部附近的文本框获得焦点时,屏幕键盘会出现并将页面内容向上移动.这很棒,也是我想要的.

When a textbox near the bottom of the screen has focus the on screen keyboard appears and moves the content of the page up. This is great and what I want.

当我有一个弹出窗口时会出现我的问题.当我的弹出窗口出现时,它实际上是全屏的.弹出窗口的子窗口是一个用户控件,上面有很多文本框.When one of the textboxes near the bottom of the page is selected, the keyboard appears but the screen doesn't move up so the keyboard is appearing over the selected textbox.

My problem occurs when I have a popup window. When my popup window appears it is practically full screen. The popup window's child is a user control which again has lots of textboxes on it. When one of the textboxes near the bottom of the page is selected, the keyboard appears but the screen doesn't move up so the keyboard is appearing over the selected textbox.

这是我用来显示弹出窗口的代码:

This is the code I use to display my popup:

if (myPopup == null)
{
    myPopup = new Popup();

    myPopup.Child = new PopupFrom();

    // open the Popup                
    myPopup.IsOpen = true;
}

我还在布局更新时手动调整弹出窗口的大小

I also manually size the popup when the layout is updated

private void popup_LayoutUpdated(object sender, object e)
{
    if (Windows.UI.ViewManagement.ApplicationView.Value == Windows.UI.ViewManagement.ApplicationViewState.FullScreenLandscape)
    {
        popup.Width = 1280;
        popup.Height = 680;
    }
    else
    {
        popup.Width = 680;
        popup.Height = 1280;
    }
}

所以我的问题是,当键盘显示并与弹出窗口底部附近的一个文本框重叠时,如何向上移动弹出窗口?

So my question is how can I move the popup window up when the keyboard is shown and overlapping one of the textboxes near the bottom of the popup?

提前致谢.

我正在使用 C# &XAML 来编写这个 windows 8 商店应用程序.

I'm using C# & XAML to write this windows 8 store app.

推荐答案

在我的应用程序中,我听 InputPane 显示/隐藏事件.这些事件告诉您键盘或其他输入设备何时显示/隐藏:

In my app, I listen to the InputPane show/ hide events. These events tell you when the keyboard or other input device is shown/ hidden:

var pane = InputPane.GetForCurrentView();
pane.Showing += pane_Showing;
pane.Hiding += pane_Hiding;

在您的事件处理程序中,您可以使用 OccludedRect 属性来确定输入区域(例如键盘)有多大.然后你可以移动你的弹出窗口,使它不覆盖这个矩形.

In your event handlers, you can use the OccludedRect property to determine how big the input area (e.g. keyboard) is. Then you can shift your popup so that it does not cover this rectangle.

这篇关于当 Surface 键盘显示在 Windows 8 商店应用程序中时,弹出窗口不会向上移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆