出现触摸键盘时WPF应用程序中Windows的高度 [英] Height of Windows in WPF Application when Touch Keyboard appears

查看:69
本文介绍了出现触摸键盘时WPF应用程序中Windows的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Windows 10编写一个可触摸的" WPF应用程序.想象一下一个包含以下网格的窗口:

I'm in the process of writing an 'touch-able' WPF Application for Windows 10. Imagine a window containing the following grid:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"></RowDefinition>
        <RowDefinition Height="*"></RowDefinition>
        <RowDefinition Height="Auto"></RowDefinition>
    </Grid.RowDefinitions>
    <TextBox Text="dsdsd"></TextBox>
    <TextBox Text="unten" Grid.Row="2" InputScope="Number"></TextBox>
</Grid>

如果我的应用程序至少使用.NET 4.6.2编译,并且其窗口已最大化,则我可以触摸下方的TextBox,然后打开touch-Keyboard.但是我看不到该控件,因为键盘将其隐藏了.此行为与Windows 8.x不同,在Windows 8.x中,打开键盘时减小了渲染画布的大小.在Windows Startbar-Search字段中执行相同操作时,该字段确实向上移动,因此我可以看到输入字段.使用最大化的explorer.exe打开键盘时,窗口会变小.

If my application is compiled using at least .NET 4.6.2 and its window is maximized, I can touch the lower TextBox and the touch-Keyboard opens. However I'm unable to see the control because the keyboard hides it. This behaviour is differs to windows 8.x where the render-canvas size was reduced when the keyboard opened. When doing the same thing in Windows Startbar-Search field, the field does move up so I can see the input field. When opening the keyboard with maximized explorer.exe the window gets smaller.

如何在WPF应用程序中实现此行为?

How can I implement this behaviour in an WPF Application?

干杯,曼努埃尔

推荐答案

根据我的记忆,如果您正确编写了XAML,即使将窗口最大化也应该可以立即使用,但是我也遇到了麻烦了,最终没有解决(我本来想解决,但高层管理人员决定不关心它).

From what I remember, if you've written your XAML right, it should work out of the box even when the window is maximized, but I also ran into trouble with this and ended up not fixing it (I would have wanted to, but higher management decided not to care about it).

从我的调查看来,微软似乎已修复Windows如何对Windows 1903 中的触摸键盘进行反应,而在 1809 及更低版本中,Windows不会调整大小窗户.您可以通过最大化资源管理器进行测试,并查看在Windows 10的两个版本中会发生什么.

From my investigations it seems like Microsoft fixed how Windows reacts to the presence of the touch keyoard in Windows 1903, while in 1809 and older versions, Windows does not resize the window. You can test this by maximizing Explorer and see what happens in both versions of Windows 10.

此外,如果您的应用已将 WindowStyle 设置为 None ,则会阻止Windows调整窗口大小以保持控件可见.我在这里的答案中谈到了这一点: WindowStyle无,然后触摸输入.

Also if your app has set WindowStyle to None, it prevents Windows from resizing your window to keep the controls visible. I talked about this in my answer here: WindowStyle None and touch input.

还可以通过检测触摸键盘的存在和位置来手动重新放置控件,并从Microsoft检出以下示例:

Also it's possible to manually reposition your controls by detecting the presence and position of the touch keyboard, check out this sample from Microsoft: TouchKeyboardNotifier

如果所有其他方法都失败了,我认为 TouchKeyboardNotifier 示例代码应该可以帮助您实现所需的功能,而无需依赖Windows行为.

If all else fails, I think the TouchKeyboardNotifier sample code should help you achieve what you need without relying on Windows behavior.

这篇关于出现触摸键盘时WPF应用程序中Windows的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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