I am looking to get a WPF window and traverse it's controls. I'm able to get the hWnd and i've found other posts on traversing the controls using a DependencyObject. How do I get a DependencyObject from a hWnd? Is it even possible?
Window window = (Window)HwndSource.FromHwnd(hWnd).RootVisual
As far as I know WPF completely replaces WinApi model with all that HWNDs. Main window has HWND of course, because it servers as container between WinApi and WPF. You can access HWND using WindowInteropHelper Class, like this. But you will not be able to traverse controls the same way you would do it with native or WinForms app. Check VisualTreeHelper for traversing control trees in WPF.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With