-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
declarative XAML - dynamic window size to screen (width and height) #21
Comments
If you want a piece of content to use a percentage of its parent's allocated bounds, you would typically use a UpdateWindowBounds();
if (Desktop.Renderer.Host is GameRenderHost<Game1> Host)
Host.Game.Window.ClientSizeChanged += (sender, e) => UpdateWindowBounds();
|
Thanks again this worked like a charm! protected void LoadUIFromFile(string path, Visibility isVisible, Dictionary<string, Func<MGButton, bool>> btnToFuncMap)
{
TextSerializer serializer = new();
serializer.Deserialize(path, out string XAMLString);
MGWindow UiWindow = MGUI.Core.UI.XAML.XAMLParser.LoadRootWindow(UIMainScreen, XAMLString, false);
// Clamp window to Screen
if (UIMainScreen.Renderer.Host is GameRenderHost<Game1> Host)
Host.Game.Window.ClientSizeChanged += (sender, e) => UpdateWindowBounds(UiWindow, Host.GetBounds());
this.UIMainScreen.Windows.Add(UiWindow);
UiWindow.Visibility = isVisible;
SetupButtonAnimations(UiWindow);
// generic type string
SetFunctionToButtonBinding<string>(UiWindow, btnToFuncMap);
}
private void UpdateWindowBounds(MGWindow window, Microsoft.Xna.Framework.Rectangle bounds)
{
window.Left = bounds.Left;
window.Top = bounds.Top;
window.WindowWidth = bounds.Width;
window.WindowHeight = bounds.Height;
} |
Hi,
is it possible to have the window object to dynamically fill the full size of the "real window"?
I tried to use the defaults with fill but then it doesnt use the full size of the screen.
I was not able to find something as "ScreenSize" "Fill" or "100%".
https://github.com/Videogamers0/MGUI/wiki/Basic-Layout#size-and-alignment
The text was updated successfully, but these errors were encountered: