0
我有以下代码。我试图让窗口在屏幕右侧的中间位置在屏幕的中间位置打开。它根本没有移动窗口的起始位置。谢谢!WPF窗口在屏幕的右边缘中间打开
int screenWidth = (int)System.Windows.SystemParameters.PrimaryScreenWidth;
int screenHeight = (int)System.Windows.SystemParameters.PrimaryScreenHeight;
cd.Top = (screenHeight/2) - (cd.Height/2);
cd.Left = screenWidth - (cd.Width + 4);
据我所知“cd”是你的Window实例吗? 如果您将代码放置在MainWindow类中,只需使用 this.Top和this.Left,而不是创建实例 – pablocity