我明白需求。
问题是,有一些WPF方法可以获取这些值 - 但是,确实如其中一位贡献者所说,不能直接获取。
解决方案不是获取所有这些变通方法,而是根据清晰的设计和开发来改变初始方法。
A)将初始主窗口设置为屏幕
B)获取包括大量有用的WPF方法在内的ActualWindow的值
C)您可以添加任意数量的窗口以获得所需的行为,例如可调整大小,最小化等...但现在您始终可以访问已加载和呈现的屏幕
请注意以下示例,周围有一些代码使使用此类方法成为必要,但它应该有效(它将为您提供屏幕每个角的点):
单个,双显示器和不同分辨率上的工作示例(在原始主窗口类中):
InitializeComponent();
[…]
ActualWindow.AddHandler(Window.LoadedEvent, new RoutedEventHandler(StartUpScreenLoaded));
路由事件:
private void StartUpScreenLoaded(object sender, RoutedEventArgs e)
{
Window StartUpScreen = sender as Window;
Dispatcher.Invoke(new Action(() =>
{
StartUpScreen.InvalidateVisual();
System.Windows.Point CoordinatesTopRight = StartUpScreen.TranslatePoint(new System.Windows.Point((StartUpScreen.ActualWidth), (0d)), ActualWindow);
System.Windows.Point CoordinatesBottomRight = StartUpScreen.TranslatePoint(new System.Windows.Point((StartUpScreen.ActualWidth), (StartUpScreen.ActualHeight)), ActualWindow);
System.Windows.Point CoordinatesBottomLeft = StartUpScreen.TranslatePoint(new System.Windows.Point((0d), (StartUpScreen.ActualHeight)), ActualWindow);
System.Windows.Application.Current.Resources["StartUpScreenPointTopRight"] = CoordinatesTopRight;
System.Windows.Application.Current.Resources["StartUpScreenPointBottomRight"] = CoordinatesBottomRight;
System.Windows.Application.Current.Resources["StartUpScreenPointBottomLeft"] = CoordinatesBottomLeft;
}), DispatcherPriority.Loaded);
}