Andre
Andre

Reputation: 15

Does MAUI support loading and displaying child forms inside a parent

We have a winforms application that uses parent/child forms written in .net framework. With .net framework being retired we are evaluating which .net core technology we should be looking at to convert our application to.

One of these technologies we are looking at is MAUI, there is some appeal to making our application cross platform however there isn't a lot there yet on this besides the very simple tutorials put out by Microsoft.

Does MAUI support loading and displaying child forms inside of a parent? Or is it like WPF and only support custom controls?

Any guidance is greatly appreciated.

Upvotes: 1

Views: 794

Answers (1)

ToolmakerSteve
ToolmakerSteve

Reputation: 21213

Depends exactly what you mean by a "form".

  • In Maui, by definition, a Page fills the window.
  • Its easy enough to make a ContentView that contains a "form". BUT, similar to WPF, you won't have some "lifecycle events" on those views. E.g. there is no event when a ContentView appears. A work-around is to put needed logic in constructor, OR have constructor attach an event handler to the containing page's OnAppearing method.

Bottom line: Its similar to WPF. But there is a work-around for whatever functionality you are accustomed to at the "form" level. (BTW, similar work-around is possible in WPF.)

For a more detailed answer, you'll need to research Maui, attempt to write equivalent Maui code. If you get stuck, Create a new question with the original WinForms code and the Maui attempt (that does not work). Explain what you want to happen, and what actually happens (or does not happen).


Bonus Tip: If you only need to run on Windows, then WinUI 3 (aka Windows Desktop App) is an alternative that may give you more functionality that you are accustomed to.

Importantly, mouse/keyboard/tooltip support in Maui is currently limited to what makes sense on mobile devices. No event for mouse hover - which also means no tooltips. No "global" key hooks (an Entry has a TextChanged event, which sees each character added to that Entry, when it has focus. But that doesn't help if you want a key to do something when no text element has focus.)

[OPINION] Full mouse/keyboard/tooltip support is often requested; I expect some solution sometime in 2023.

Bonus Tip #2: WinForms has been migrated to .Net 6+. [OPINION] Microsoft seems committed to keeping it alive. I wouldn't develop a new app on it, but for legacy WinForms code that would be the "cheapest" development option. Long-term, I would favor Maui for cross-platform, WinUI 3 for Windows only.

Upvotes: 3

Related Questions