The location of popup and other pop-up windows in WPF is not correct (partial left or right)

Source: Internet
Author: User

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)

Related Article

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.