Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Height of Windows in WPF Application when Touch Keyboard appears

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>

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.

How can I implement this behaviour in an WPF Application?

Cheers, Manuel

like image 773
Manuel R. Wenk Avatar asked May 24 '16 15:05

Manuel R. Wenk


1 Answers

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).

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.

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.

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

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

like image 157
Shahin Dohan Avatar answered Nov 03 '22 03:11

Shahin Dohan