Is there a way to directly get the Window object a control is on?开发者_开发技巧
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.
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:
stackoverflow: get active window(s) in wpf
A bit late, but the following works pretty fine for me.
var ownerWindow = Window.GetWindow(yourControl);
精彩评论