private void OnAddedToVisualTree()
{
if(Parent != Application.LayoutRoot)
{
throw new InvalidOperationException("Dialogs must be added to the LayoutRoot of an application");
}
if (MaxHeight > 0)
{
this.Height = Math.Min(MaxHeight, Application.LayoutRoot.Height - 2);
}
else
{
this.Height = Application.LayoutRoot.Height - 2;
}
this.CenterVertically();
this.FillHoriontally();
ConsoleApp.Current.FocusManager.TryMoveFocus();
Application.FocusManager.SubscribeForLifetime(nameof(FocusManager.StackDepth), () =>
{
if(Application.FocusManager.StackDepth != myFocusStackDepth)
{
closeButton.Background = Application.Theme.DisabledColor;
}
else
{
closeButton.Background = Application.Theme.H1Color;
}
}, this.LifetimeManager);
}