adospace / reactorui-maui

MauiReactor is a MVU UI framework built on top of .NET MAUI
MIT License
597 stars 50 forks source link

Set Window size? #44

Closed phollyer closed 1 year ago

phollyer commented 1 year ago

Hi Ado,

I've just started looking at Maui Reactor and really like what you're doing 👍

Is it currently possible to set the window size for a Desktop app? I'm interested in setting the start up size along with minimums and maximums for height and width. I've been through the docs but couldn't find anything and I've seen some examples wrt Maui, but can't figure out how to use those with ReactorUI or if they're even relevant.

(I've just started my .NET journey, so it's all a bit new at the moment...)

Thanks Paul

adospace commented 1 year ago

Hi, Windows support is somewhat still primitive in dotnet maui and so is in MauiReactor. Anyway using the current version of MauiReactor you can do something like this:

Page _topLevelPage;

new ContentPage(r => SetupWindow(r))
{
}

void SetupWindow(MauiControls.ContentPage page)
{
      _topLevelPage = page
      if (MauiControls.Application.Current != null && _topLevelPage != null)
      {
          MauiControls.Application.Current.Dispatcher.Dispatch(() =>
          {
              if (_topLevelPage.Parent is Window parentWindow)
              {
                  parentWindow.Title = "My Title";
                  parentWindow.Width=....
                  ...
              }
          });
      }
}

in future versions, I'm going to introduce some helper methods that should simplify the access to Window properties.

Right now only the title of the window is accessible easily using a shortcut function like the one shown here:

new ContentPage()
    .WindowTitle("MyTitle")
phollyer commented 1 year ago

Many Thanks, I'll try implementing it tomorrow.

adospace commented 1 year ago

The latest version of MauiReactor contains some enhancements on Window support, please take a look at the new documentation page: https://adospace.gitbook.io/mauireactor/components/window