0

I'm writing an 'touch-able' WPF Application for Windows 10 using .NET 5.

I've been looking around Stack Overflow to find answer however i didn't find any, that's why I'm asking it.

First of all, my MainWindow is not 'Maximized' and my WindowStyle is not 'None'.

<Window
    x:Class="App1234.Views.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:prism="http://prismlibrary.com/"
    xmlns:notifications="clr-namespace:Notification.Wpf.Controls;assembly=Notifications.Wpf"
    Title="App1234"
    d:DesignHeight="1200"
    d:DesignWidth="1920"
    prism:ViewModelLocator.AutoWireViewModel="True"
    Background="{DynamicResource MaterialDesignPaper}"
    FontFamily="{materialDesign:MaterialDesignFont}"
    Loaded="MainWindow_OnLoaded"
    TextElement.FontSize="14"
    TextElement.FontWeight="Medium"
    TextElement.Foreground="{DynamicResource MaterialDesignBody}"
    mc:Ignorable="d">

I can touch the lower TextBox and the touch-Keyboard opens. However I'm unable to see the control because the keyboard hides it. I would like to "resize" my application in order to still see the control

How can I implement this behaviour in an WPF Application?

Thank you, Arthur

UPDATE:

We also launched our application as administrator without the uiAcess flag. The solution (in addition to the reply) was to remove the administrator requirement.

Arthur
  • 3
  • 2

1 Answers1

1

I am working on the same project as OP.

We found about this https://github.com/microsoft/WPF-Samples/tree/master/Input%20and%20Commands/TouchKeyboard. On this sample Microsoft gives some code to fix the issue for WPF with .net framework.

Now this works well for their usecase. But I've been trying to implement their code with a NET 5 project. And to nobody's surprise this does not appear to be possible (the app simply crashes at the starts and overflows)

So does anyone know if there is a way to either make an app work with NET 5 and .net framework at the same time ?

Or

Port Microsoft's fix in Net 5 so we can use it too !

Thx.

Update

So after further re-search I found out how to fix our issue with the help of this post http://mheironimus.blogspot.com/2015/05/adding-touch-keyboard-support-to-wpf.html. and this one https://stackoverflow.com/a/57463543/14620831

    private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
var elementWithFocus = Keyboard.FocusedElement as FrameworkElement;

    if ((elementWithFocus != null) && ((e.PreviousSize.Height > e.NewSize.Height)))
    {
        elementWithFocus.BringIntoView();
    }
}

Both of these links helped understand what went wrong. First the xaml had to be coded in a way that windows can resize the app when keyboard shows up, basically a scrollviewer with stackpanel inside is alright.

But this is only enough to make the window resize, this is when the code snippet allows the scrollviewer to "scroll" to the clicked element and bring it up above the virtual touch keyboard.

THX to the other posters, hope this post helps others too.