调整的WinRT页面显示当屏幕上的键盘

编程入门 行业动态 更新时间:2024-10-27 16:24:26
本文介绍了调整的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页面显示当屏幕上的键盘

本文发布于:2023-11-03 06:22:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554437.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:键盘   页面   屏幕上   WinRT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!