ModalRoot and PopupRoot
Introduction
Modal Popups
Example - Adding a Popup
var popupButton = new Button();
popupButton.AddToRoot();
popupButton.Y = 50;
popupButton.X = 50;
popupButton.Text = "Show Modal";
popupButton.Click += (_, _) =>
{
ShowPopup("Close me", isModal: true);
};
void ShowPopup(string text, bool isModal)
{
var container = isModal ?
GumService.Default.ModalRoot : GumService.Default.PopupRoot;
var button = new Button();
button.Text = "Close Me";
button.Width = 200;
button.Height = 200;
var buttonVisual = button.Visual;
buttonVisual.YOrigin = RenderingLibrary.Graphics.VerticalAlignment.Center;
buttonVisual.YUnits = global::Gum.Converters.GeneralUnitType.PixelsFromMiddle;
buttonVisual.XOrigin = RenderingLibrary.Graphics.HorizontalAlignment.Center;
buttonVisual.XUnits = global::Gum.Converters.GeneralUnitType.PixelsFromMiddle;
container.Children.Add(button.Visual);
button.Click += (_, _) =>
{
buttonVisual.RemoveFromManagers();
buttonVisual.Parent = null;
};
}
Example - Adding a Popup from Gum Element
Last updated
Was this helpful?

