Original: Popup in WPF, such as pop-up window position is not correct (partial left or right)
1. Situation
Normal situation: Some special cases:
In the normal computer can be displayed correctly, is the first case, the same code in different computers will show a different location, the original windows in order to meet
Different needs of the user, left-handed and right-handed, will show a different situation, on the computer that displays the exception, enter table in the run if the content appears:
is the setting in the table PC settings, click on it, then go to other and you can see
With right-handed and left-handed, these two options are the root of the problem.
2. So what to do in the code, certainly not let the user to manually modify it, then the solution is as follows:
1 Public Static voidsetalignment ()2 {3 //gets whether the system is left-handed (true) or right-handed (false)4 varIfleft =systemparameters.menudropalignment;5 6 if(Ifleft)7 {8 //Change to false9 vart =typeof(SystemParameters);Ten varfield = T.getfield ("_menudropalignment", BindingFlags.NonPublic |bindingflags.static); OneField. SetValue (NULL,false); A -Ifleft =systemparameters.menudropalignment; - } the}
View Code
Reference: Http://stackoverflow.com/questions/18113597/wpf-handedness-with-popups
and https://social.msdn.microsoft.com/Forums/vstudio/en-US/19ef3d33-01e5-45c5-a845-d64f9231001c/ Popup-positioningalignments?forum=wpf
Http://www.tomshardware.com/forum/37096-63-popups-menus-wrong-side
The location of popup and other pop-up windows in WPF is not correct (partial left or right)