MonoGame embedded inside a WPF app as a dotnet new
template.
This template uses .NET Core 6. If you're having trouble getting it to compile make sure you've updated to the latest version. I have confirmed that it works with:
To install the dotnet new
template, clone this repository locally and install the template from a local directory.
dotnet new install MonoGame.WpfCore
After the template is installed you should see it in the list. To create a new project, first create an empty directory then run the template.
mkdir MyLevelEditor
cd MyLevelEditor
dotnet new monogamewpf
All done! Open the solution and run the project.
There's no magic here.
MonoGame.Framework.WindowsDX
NuGet package. The same package can be used in your game.MonoGameContentControl
is a standard WPF control in every other way.I've been using and refining the MonoGameContentControl
in my own projects for many years. Everything else in this template was built from the ground up using the latest .NET technologies.
UseWPF
flag introduced in .NET Core 3.0 we can build WPF projects in the new csproj
format.All of the code used to embed MonoGame in WPF is included in this template. You can edit and customize it however you like.
MonoGameViewModel
as an example of how to get started. If you use a different view model architecture, just change it.MonoGame.Content.Builder.Task
package so that it can automatically build your Content.mgcb
file. You can load content using the Content
manager just like you do in your games. If your editor doesn't need this you can simply remove it and the .config\dotnet-tools.json file.