调整的WinRT页面显示当屏幕上的键盘 [英] Resize winrt page when on on screen keyboard showing

查看:204
本文介绍了调整的WinRT页面显示当屏幕上的键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows 8.1的C#应用​​程序,显示了一个相当大的文本页面(几乎涵盖了所有的页面的,其写作的应用程序)。

I have a Windows 8.1 C# app that shows a page with a pretty big textbox (covering almost all of the page; its a writing app).

当屏幕键盘出现,它会覆盖文本框的一半。
我想调整文本框(甚至整个页面),所以它不是通过键盘覆盖。

When the on screen keyboard shows up, it overlays half of the textbox. I would like to resize the textbox (or even the whole page) so it isnt covered by the keyboard.

我现在thrying这个使用来实现静态InputPane和订阅它的显示和隐藏事件。然后,我尝试使用在EventArgs的提供的occuled矩形改变我的文本框的边缘。这工作,但因为我的网页仍是屏幕的高度,使其中途滚动它的底部。

I am now thrying to achieve this using the static InputPane and subscribing to its showing and hiding events. I then try to change the margins of my textbox using the occuled rectangle provided in the eventargs. This works, but since my page is still the height of the screen it scrolls it halfway to the bottom.

public MainPage()
{
    var inputPane = InputPane.GetForCurrentView();
    inputPane.Showing += this.InputPaneShowing;
    inputPane.Hiding += this.InputPaneHiding;
}

void InputPaneHiding(InputPane sender, InputPaneVisibilityEventArgs args)
{
    this.EditBox.Margin = new Thickness();
}

private void InputPaneShowing(InputPane sender, InputPaneVisibilityEventArgs args)
{
    this.EditBox.Margin = new Thickness(0, 0, 0, args.OccludedRect.Height);
}



在尝试了这一点,我得到这个心不是理想的解决方案的感觉,但我还没有得到一个更好的主意。理想我想这会是这样的垂直分割时,你必须打开的应用程序,但随后水平与键盘在底部和应用程序的唯一可用尺寸键盘上方。

While trying this out I'm getting the feeling this isnt the ideal solution, but I havent got a better idea. Ideally I'd think it would be something like the vertical split when you have to apps opened, but then horizontally with the keyboard at the bottom and the app only the size available above the keyboard.

任何想法,如果这是可能的吗?

Any idea if this is possible?

推荐答案

由于要处理自己的接口闭塞,你应该设置该属性 EnsuredFocusedElementInView从InputPane.Showing EventArgs的真 。它可以防止接口自动滚动。

Since you are handling the interface occlusion yourself you should set the property EnsuredFocusedElementInView from InputPane.Showing eventargs to true. It would prevent interface from automatically scrolling.

 private void InputPaneShowing(InputPane sender, InputPaneVisibilityEventArgs args)
 {
    args.EnsuredFocusedElementInView = true;
    this.EditBox.Margin = new Thickness(0, 0, 0, args.OccludedRect.Height);
 };

这篇关于调整的WinRT页面显示当屏幕上的键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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