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