public Monitor(UIElement element) { this.Element = element; this.HwndSource = ScreenLocation.FindTopLevelHwndSource(element); this.Element.LayoutUpdated += new EventHandler(this.OnLayoutUpdated); PresentationSource.AddSourceChangedHandler((IInputElement)element, new SourceChangedEventHandler(this.OnPresentationSourceChanged)); }
private void OnPresentationSourceChanged(object sender, SourceChangedEventArgs args) { this.HwndSource = ScreenLocation.FindTopLevelHwndSource((UIElement)sender); this.TryUpdateLocation(); }