Search code examples
wpfrotationwindows-8.1tablet

How to handle rotation of WPF Application to be used on Tablets


I'm currently working on a WPF application which will run on Windows 8.1 tablet and I don't find any posts about the following issue :

My application needs to be full screen, so, I set for my views :

 WindowState="Maximized"
 WindowStyle="ToolWindow"

All right - my application will be displayed in full screen mode:

But, if I rotate the tablet a space is allocated and the application is not in full screen.

enter image description here

I don't want this scenario to happen, the application should stay always in full screen.

I tried to listen SystemEvents.DisplaySettingsChanged event and manually set full screen:

SystemEvents.DisplaySettingsChanged += Current_SizeChanged;

private void Current_SizeChanged(object sender, EventArgs eventArgs)
{
    this.WindowStyle = WindowStyle.None;
    this.ResizeMode = ResizeMode.NoResize;
    this.WindowState = WindowState.Maximized;    
    this.UpdateLayout();
}

As you can see, i tried even to update layout, but still, not working! What is strange, is the fact that if you start the application in any position but not in the normal one, it will work. For ex: if the application is started in portrait mode, rotation will not change the dimensions of the window, but if you run the application starting from landscape mode... the bug appears.

You can debug this issue using Ctrl + Alt + Arrows.

Any suggestions?

Edit: It seems that the problem is caused by keyboard. The reserved zone is for keyboard, but i don't find a way to resize to full screen. Actual width, Width and Desired Width are all the same...

Edit2: This bug can be reproduced only on Windows 8.1


Solution

  • A workaraund for this bug is to listen to DisplaySettingsChanged and manually set windows state to normal and after windows state to maximized, like below :

      SystemEvents.DisplaySettingsChanged += Current_SizeChanged;
    
    
    
      private void Current_SizeChanged(object sender, EventArgs eventArgs)
            {
                this.WindowState = WindowState.Normal;
                this.WindowState = WindowState.Maximized;
    
    
            }
    

    This is caused by :

      WindowStyle="ToolWindow" 
    

    Hope microsoft will solve this bug (I submitted the bug on WPF threads on MSDN). Thank you for your help!