WPF用户控件中的按钮事件里,怎么取得其所在的Window窗体
WPF用户控件中的按钮事件里,如何取得其所在的Window窗体?
如T, 谢谢!
------解决方案--------------------
可以参照我博客里面的http://blog.****.net/fallincloud/article/details/6960255
FindParent的方法,用法Window w = FindParent<Window>(this);
------解决方案--------------------
或者使用App.Current.MainWindow可以获得当前窗口
------解决方案--------------------
可以用这个方法获取控件所在窗体
Button button = sender as Button;
Window targetWindow = Window.GetWindow(button);
如T, 谢谢!
------解决方案--------------------
可以参照我博客里面的http://blog.****.net/fallincloud/article/details/6960255
FindParent的方法,用法Window w = FindParent<Window>(this);
------解决方案--------------------
或者使用App.Current.MainWindow可以获得当前窗口
------解决方案--------------------
可以用这个方法获取控件所在窗体
Button button = sender as Button;
Window targetWindow = Window.GetWindow(button);