Is there a way to directly get the Window object a control is on?
+5
A:
Assuming the Control is directly below the Window, you can call GetParent on the LogicalTreeHelper.
You may, of course, need to Use the LogicalTreeHelper
to traverse the tree if the Control is not a direct descendant.
IanR
2010-07-26 22:00:27
That's better than what I currently have, but I'm a bit annoyed that there isn't a GetWindow method.
Jonathan Allen
2010-07-26 22:39:52
+1
A:
Most likely you are on the applications active window in the moment you interact with the control.
So in that case, this other post on stackoverflow could be helpful too:
SwissCoder
2010-07-26 22:09:44
That looks like it would be very fragile for my use case, but I;ll give you a point because it would be really useful when displaying a pop-up window with CenterOwner set.
Jonathan Allen
2010-07-26 22:41:23