Troubleshooting WPF Popup Controls blocking other programs

Source: Internet
Author: User

 Public classpopupnontopmost:popup{ Public StaticDependencyProperty Topmostproperty =Window.TopmostProperty.AddOwner (typeof(popupnontopmost),NewFrameworkpropertymetadata (false, ontopmostchanged));  Public BOOLTopmost {Get{return(BOOL) GetValue (Topmostproperty); }        Set{SetValue (topmostproperty, value);} }    Private Static voidontopmostchanged (DependencyObject obj, DependencyPropertyChangedEventArgs e) {(obj aspopupnontopmost).    UpdateWindow (); }    protected Override voidonopened (EventArgs e) {UpdateWindow (); }    Private voidUpdateWindow () {varhwnd = ((HwndSource) presentationsource.fromvisual ( This. Child)).        Handle;        Rect rect; if(GetWindowRect (hwnd, outrect)) {SetWindowPos (hwnd, topmost? -1: -2, Rect. Left, rect. Top, (int) This. Width, (int) This. Height,0 ); }    }    #regionP/invoke Imports & Definitions[StructLayout (layoutkind.sequential)] Public structRECT { Public intLeft ;  Public intTop;  Public intRight ;  Public intBottom; } [DllImport ("user32.dll" )]    [return: MarshalAs (unmanagedtype.bool)]Private Static extern BOOLGetWindowRect (IntPtr hWnd, outRECT LpRect); [DllImport ("User32", EntryPoint ="SetWindowPos" )]    Private Static extern intSetWindowPos (IntPtr hWnd,intHwndinsertafter,intXintYintCxintCyintwflags); #endregion}
View Code

Troubleshooting WPF Popup Controls blocking other programs

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.