获取 MainWindow 的位置/宽度/高度 [英] Getting position/width/height of MainWindow

查看:30
本文介绍了获取 MainWindow 的位置/宽度/高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道获取有关 MainWindow 的当前位置和宽度/高度的信息的最佳方法.我想在主窗口内保留一个子窗口,所以我想在子窗口的移动功能期间检查 MainWindows 边框的坐标.我只能找到 Window.LocationChanged 事件,但它并没有以令人满意的方式解决我的问题.有没有更好的选择?

I'm wondering about the best way to get information about the current position and width/height of the MainWindow. I want to keep a child window inside the main window so I want to check the coordinates of the MainWindows borders during the move function of the child window. I could only find the Window.LocationChanged event but it doesn't solve my problem in a satisfying way. Are there better options?

推荐答案

您可以通过 Application.Current.MainWindow.LeftApplication 访问整个代码中主窗口的位置.Current.MainWindow.Top,分别.希望这会有所帮助.

You can access the position of the main window all over your code via Application.Current.MainWindow.Left and Application.Current.MainWindow.Top, respectively. Hope this will help.

这篇关于获取 MainWindow 的位置/宽度/高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆