WPF popup Win8.0 bug horizontaloffset popup position offset

Source: Internet
Author: User

Problem Description Reference

WPF Client "jdagent Desktop Assistant" Development in detail (iv) win8.0 Bug of Popup control

After the development of the program, we found in the multi-operating system testing: win8.0 System popup Popup position is always wrong.

Such as:

winxp/vista/win7/win8.1 where the Windows right-click menu pops up (the red circle is the mouse pointer position)

Win8.0 where the Windows right-click menu pops up (the red circle is the mouse pointer position)

The Popup control is also the case. You need to judge the version of Windows in your code. If the win8.0 popup HorizontalOffset, the Verticaloffset value needs to be adjusted.

Solution one.. To get the current system version through the registry

Because the win8.0 that Environment.OSVersion.Version gets is the same as win8.1 information.

Get the win8.0 code from the registry to 6.2, win8.1 code 6.3

       public static string Setregister ()       {           string regpath = "Software\\microsoft\\windows nt\\currentversion";           RegistryKey Uaes = Registry.LocalMachine.OpenSubKey (Regpath,               Registrykeypermissioncheck.readwritesubtree, System.Security.AccessControl.RegistryRights.FullControl);           if (Uaes = = null)               Uaes = Registry.LocalMachine.CreateSubKey (Regpath, Registrykeypermissioncheck.readwritesubtree );           var registdata = Uaes. GetValue ("CurrentVersion"). ToString ();           return registdata;       }

Note that this method requires the addition of administrator privileges:

Solution Two. Modifies whether the pop-up menu is left-aligned or right-aligned relative to the corresponding menu item. (Group leader pull-out)

  

        public static void Fixpopupbug ()        {            var ifleft = systemparameters.menudropalignment;            if (ifleft)            {                var t = typeof (SystemParameters);                var field = T.getfield ("_menudropalignment", BindingFlags.NonPublic | bindingflags.static);                Field. SetValue (null, FALSE);            }                   }

The win8.0 pop-up menu pops to the left to the right by default. Called in the App.xaml.cs constructor.

WPF popup Win8.0 bug horizontaloffset popup position offset

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.