Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7046759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:41:19+00:00 2026-05-28T02:41:19+00:00

I have a WPF app that I’m testing on a Samsung XE700T1A tablet. I

  • 0

I have a WPF app that I’m testing on a Samsung XE700T1A tablet. I have no other tablets to test it on. Upon launching the app, when I rotate the tablet to portrait mode, my UI elements stop responding to touch. They continue to ignore touch after rotating back to landscape again, but then after rotating a third time back to portrait, touch works. Further rotations seem to have indeterminate results. Sometimes touch works, sometimes you have to keep rotating to get it back. I have seen an occasional variation in that initial sequence, but for the most part it appears very consistent.

In order to narrow down the range of possibilities, I created a simple WPF app to demonstrate the issue. Here is the code:

MainWindow.xaml

<Window x:Class="RotationBug.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <TextBlock x:Name="DisplayText" 
                   HorizontalAlignment="Center" 
                   VerticalAlignment="Center"
                   Text="I'm happy." />

        <Button Grid.Row="1" 
                Height="22" 
                Width="80" 
                Margin="0,0,0,20" 
                Click="OnButtonPress"
                Content="Depress Me" />
    </Grid>
</Window>

MainWindow.xaml.cs

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void OnButtonPress(object sender, RoutedEventArgs e)
    {
        DisplayText.Text = DateTime.UtcNow.Ticks.ToString();
    }
}

This simple demo app is also hosted here on GitHub.

Does anyone know what is causing this issue? Or how to resolve it? Can anyone reproduce this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:41:20+00:00Added an answer on May 28, 2026 at 2:41 am

    This is apparently an issue known internally at Microsoft where “WPF’s touch system does not always detect resolution changes correctly.“

    Paraphrasing comments there, the workaround is to subscribe to SystemEvents.DisplaySettingsChanged and after a short delay, repost WM_DISPLAYCHANGE to the window titled “SystemResourceNotifyWindow” in the current thread.

    However, the actual code posted there is not practical for anyone outside Microsoft. The code below will work for the rest of us. I’ve posted a sample solution here on GitHub.

    class NativeRotationFix
    {
        private readonly Window window;
    
        private const string MessageWindowTitle = "SystemResourceNotifyWindow";
        private const uint WM_DISPLAYCHANGE = 0x007E;
        private const int Delay = 500;
    
        private int width;
        private int height;
        private int depth;
    
        public delegate bool WNDENUMPROC(IntPtr hWnd, IntPtr lParam);
    
        [DllImport("user32.dll")]
        public static extern bool EnumThreadWindows(uint dwThreadId, WNDENUMPROC lpfn, IntPtr lParam);
    
        [DllImport("user32.dll")]
        public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
    
        [DllImport("user32.dll")]
        public static extern bool PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
    
        [DllImport("kernel32.dll")]
        static extern uint GetCurrentThreadId();
    
        public NativeRotationFix(Window window)
        {
            this.window = window;
            SystemEvents.DisplaySettingsChanged += OnDisplaySettingsChanged;
        }
    
        ~NativeRotationFix()
        {
            SystemEvents.DisplaySettingsChanged -= OnDisplaySettingsChanged;
        }
    
        private void OnDisplaySettingsChanged(object sender, EventArgs e)
        {
            new DispatcherTimer(TimeSpan.FromMilliseconds(Delay), DispatcherPriority.Normal, (s, a) =>
            {
                WindowInteropHelper interopHelper = new WindowInteropHelper(window);
    
                Screen screen = Screen.FromHandle(interopHelper.Handle);
                width = screen.Bounds.Width;
                height = screen.Bounds.Height;
                depth = screen.BitsPerPixel;
    
                uint threadId = GetCurrentThreadId();
                EnumThreadWindows(threadId, PostToNotifyWindow, IntPtr.Zero);
    
                (s as DispatcherTimer).Stop();
    
            }, Dispatcher.CurrentDispatcher);
        }
    
        private bool PostToNotifyWindow(IntPtr hwnd, IntPtr lparam)
        {
            StringBuilder buffer = new StringBuilder(MessageWindowTitle.Length + 1);
    
            if (GetWindowText(hwnd, buffer, buffer.Capacity) <= 0) return true;
            if (buffer.ToString() != MessageWindowTitle) return true;
    
            PostMessage(hwnd, WM_DISPLAYCHANGE, new IntPtr(depth), new IntPtr(MakeLong(width, height)));
            return false;
        }
    
        private static int MakeLong(int low, int high)
        {
            return (int)((ushort)low | (uint)high << 16);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF App that implements a ListView. I would like to show
I have a WPF app that is using the MVVM pattern. Hooking up buttons
I have a wpf app that needs to communicate(exchange data) with a custom designed
We have a WPF app that allows our users to download encrypted content and
Context: I have a WPF App that uses certain unmanaged DLLs in the D:\WordAutomation\MyApp_Source\Executables\MyApp
This is an interesting conundrum. We have a WPF app that has a Vista-like
I have a WPF app, my purpose is that the app can be automatically
I have a folder in my WPF app Images that has several .png files
Ok, I have a ResourceDictionary definition that I used for a WPF app below:
I have a WPF application that is a fullscreen kiosk app. It's actually a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.