Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 WPF 中,当显示一个新窗口时,它会在水平和垂直方向上偏移大约 10 个像素。有没有一种简单的方法来防止这种情况,所以窗口直接在触发它的窗口上打开?(它们的大小相同 - 认为它类似于安装程序的行为)
您可以将新窗口的 Left 和 Top 属性设置为与所有者窗口相同。您应该在调用 Show 或 ShowDialog 方法之前执行此操作。
祝你好运,
M·摩西
您应该将WindowStartupLocation所有窗口的属性设置为CenterScreen值。
WindowStartupLocation
CenterScreen