private void OnChildChanged(DependencyPropertyChangedEventArgs e) { FrameworkElement child = (FrameworkElement)e.NewValue; if (_hwndSource != null) { SetRootVisual(child); } }