public override void OnApplyTemplate()
{
base.OnApplyTemplate();
// Solves issue where ChildWindow does not center when browser is not active
var contentRoot = GetTemplateChild("ContentRoot") as FrameworkElement;
if (contentRoot != null)
{
bool centerChildWindow = (HorizontalAlignment == HorizontalAlignment.Center) && (VerticalAlignment == VerticalAlignment.Center);
if (centerChildWindow)
{
Dispatcher.BeginInvoke(CenterInScreen);
}
}
else
{
Log.Debug("Cannot center childwindow because 'ContentRoot' cannot be found");
}
}