Monogame in Xamarin / .NET Maui

Is there an actual way to use both Xamarin Forms and Monogame together? I want to create a 3D editor of sorts using a Monogame 3D sub-window for the 3D space, and Xamarin for the UI (like the Unity editor for example). Can I do this with Monogame, or should I use a different 3D engine for Xamarin. If so, any recommendations?

Just use Monogame.forms

I was able to do this with native Xamarin.Android, Xamarin.iOS and a fork off MonoGame 3.71:

The biggest problem is that MonoGame is really sloppy about cleaning up after itself, I had to fix a ton of bugs related to shutting down and restarting new instances of MonoGame in the same app. Also the architecture of MonoGame.iOS is a nightmare, I had to add factory methods 3 layers deep just to subclass the monogame viewcontroller, and sorting out the touches & gestures is a complete headache.

It turned out pretty awesome though, I used it for a note-taking app
Everytime the user opens the notebook view, it’s a new instance of MonoGame with native Android & iOS controls layered on top.

Also the recommendation MonoGame.Forms is wrong, that’s for embedding MonoGame in a WinForms project, not Xamarin.Forms.


Are there any tutorials or guides for using this fork? I want to make a multi-platform editor with Xamarin UI and Monogame as a 3D view in the middle (or any other good 3D engines compatible with Xamarin)

Afaik Not really. I’m still trying to find a way to render stuff onscreen before compiling myself.

Just use ImGUI. It’s definitely better than whatever mgforms is, and specializes exactly on making editors.

Yeah I’ll go ahead and spin up a really basic HelloWorld that can spin up MonoGame inside a Xamarin.Android and Xamarin.iOS app, and then another full-blown MVVM example that uses ReativeUI to move all the business logic into a viewmodel.
Once that is up and running, I can start working on getting these changes rolled into the main MonoGame repo.

The end result of all this is that you end up with a native Android and iOS app, with MonoGame running in the middle of it. The recommendation to use ImGui might work on mobile, but the end result UX definitely doesn’t match Android & iOS. If you plan on putting something on an app store, I wouldn’t use imgui, iOS users in particular get upset if an app doesn’t follow Apple’s best practices. YMMV

1 Like