protected override sealed HWND BuildWindowOverride(HWND hwndParent)
{
HwndSourceParameters hwndSourceParameters = new HwndSourceParameters();
hwndSourceParameters.WindowStyle = (int)(WS.VISIBLE | WS.CHILD | WS.CLIPSIBLINGS | WS.CLIPCHILDREN);
hwndSourceParameters.ParentWindow = hwndParent.DangerousGetHandle();
_hwndSource = new HwndSource(hwndSourceParameters);
_hwndSource.SizeToContent = SizeToContent.Manual;
// Set the root visual of the HwndSource to an instance of
// HwndSourceHostRoot. Hook it up as a logical child if
// we are on the same thread.
HwndSourceHostRoot root = new HwndSourceHostRoot();
_hwndSource.RootVisual = root;
root.OnMeasure += OnRootMeasured;
AddLogicalChild(_hwndSource.RootVisual);
SetRootVisual(Child);
return new HWND(_hwndSource.Handle);
}