private object SetRootVisual(object arg)
{
Debug.Assert(_hwndSource != null);
FrameworkElement child = arg as FrameworkElement;
if (child == null && arg is Uri) {
child = (FrameworkElement)Application.LoadComponent((Uri)arg);
}
HwndSourceHostRoot root = (HwndSourceHostRoot)_hwndSource.RootVisual;
root.Child = child;
// Invalidate measure on this HwndHost so that we can remeasure
// ourselves to our content.
InvalidateMeasure();
return null;
}