Wpf – Finding the handle to a WPF window

handlewindowwpf

Windows forms had a property win1.Handle which, if I recall, returns the handle of the main window handle?

Is there an equivalent way to get the handle of a WPF Window?

I found the following code online,

IntPtr windowHandle = new WindowInteropHelper(Application.Current.MainWindow).Handle;

but I don't think that will help me because my application has multiple windows.

Thanks!!

Best Answer

Well, instead of passing Application.Current.MainWindow, just pass a reference to whichever window it is you want: new WindowInteropHelper(this).Handle and so on.

Related Topic