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

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

问题描述

我有一个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.

当我有一个弹出窗口时,会发生我的问题.当我的弹出窗口出现时,它实际上是全屏的.弹出窗口的子级是一个用户控件,该控件上再次有很多文本框.选择页面底部附近的一个文本框时,键盘会出现,但屏幕不会向上移动,因此键盘会出现在所选文本框的上方.

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.

推荐答案

在我的应用中,我收听

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;

在事件处理程序中,您可以使用

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.

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

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