MSDN Community

Getting Started with .NET MAUI for Desktop Applications

Hi everyone, I'm new to .NET MAUI and I'm trying to build a cross‑platform desktop app using C#. I've followed the official docs, but I'm hitting a snag with window handling on Windows. Any tips?

What I've tried:

  • Created a new MAUI project with dotnet new maui
  • Added a simple Button that opens a new window
  • Implemented IWindow for custom sizing

When I run the app, the new window appears but it's invisible on Windows 10. It works fine on macOS.

Any ideas on what I'm missing?

Comments

MikeSharpSep 2, 2024 08:15

Make sure you set Window.Width and Window.Height after the window is created. Also, add DispatcherQueue.TryEnqueue around the sizing code.

JaneDoeSep 2, 2024 10:03

Thanks, Mike! That solved it. I also had to enable UseMauiWinUI in the csproj.