Integrating MonoGame window into XAML

I am basically trying to embed the game window into an XAML view.

I have tried creating the VS19 project template “MonoGame Windows Universal Application (XAML)”, but the csproject of the template is Unsupported, visual studio unable to open the project essentially.

I have also tried looking at the code and using it, but the main function being MonoGame.Framework.XamlGame<T>.Create(...) which I am unable to find within the Monogame.Framework, neither in the API documentation. I have found a reference here but maybe it is outdated. I have tried importing all nugets available without success of finding such XamlGame object.

I am a bit lost, and would appreciate help, since I believe it must not be that hard, just that I am not used to MonoGame yet. So far I have not been able to inject in any of the templates the game window into an XAML view. I am using VS19 and I target .Net framework (maybe that’s the issue?).

I would appreciate any help!!

Welcome @Marc1. Which version of MonoGame are you trying this with? If you’re using MonoGame 3.8 it is better to target .NET Core 3.1. More likely it is a problem with your Windows Universal SDK, I have had this problem. I’d suggest you try running the VS 2019 installer, removing Universal Windows Development Platform and adding it back in again.


Hi @Marc1 Welcome to the Community!

As asked already, which MG are you using? 3.7.1 is not compatible with VS19 out of the box.

Happy Coding!

Hi guys thanks for the quick answer!

I was using the latest MG, but I haven´t tried with the uninstalling @Synammon suggested.

In any case I found a very nice example where MG is embedded within WPF and it runs out of the box, no changes needed:

Under further review @Synammon was right, I could start it reinstalling the Windows Universal SDK, thanks!!