AvaloniaInside.MonoGame 1.0.2

dotnet add package AvaloniaInside.MonoGame --version 1.0.2
                    
NuGet\Install-Package AvaloniaInside.MonoGame -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AvaloniaInside.MonoGame" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AvaloniaInside.MonoGame" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="AvaloniaInside.MonoGame" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AvaloniaInside.MonoGame --version 1.0.2
                    
#r "nuget: AvaloniaInside.MonoGame, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AvaloniaInside.MonoGame@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AvaloniaInside.MonoGame&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=AvaloniaInside.MonoGame&version=1.0.2
                    
Install as a Cake Tool

AvaloniaInside.MonoGame

NuGet NuGet Downloads License: MIT

AvaloniaInside.MonoGame enables seamless integration of MonoGame content within Avalonia UI applications. Embed MonoGame games and graphics directly into your cross-platform Avalonia controls.

✨ Features

  • 🎮 Easy Integration - Add MonoGame content to Avalonia apps with just a control
  • 🖼️ Control-Based - Use MonoGame as a standard Avalonia XAML control
  • 🎯 Resolution Rendering - Built-in ResolutionRenderer for resolution-independent rendering
  • 🔄 Cross-Platform - Works on Desktop platforms (Windows, macOS, Linux)
  • Simple API - Minimal setup required to get started

📦 Installation

Install the package to your project using the command below or visit the NuGet package page for other installation methods.

dotnet add package AvaloniaInside.MonoGame

Or via Package Manager Console:

Install-Package AvaloniaInside.MonoGame

📋 Requirements

  • .NET 8.0 or .NET 10.0
  • Avalonia 11.3.9 or higher
  • MonoGame.Framework.DesktopGL 3.8.4.1 or higher

🚀 Quick Start

1. Create Your MonoGame Class

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

public class MyExampleGame : Game
{
    private GraphicsDeviceManager _graphics;
    private SpriteBatch _spriteBatch;

    public MyExampleGame()
    {
        _graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
    }

    protected override void LoadContent()
    {
        _spriteBatch = new SpriteBatch(GraphicsDevice);
    }

    protected override void Update(GameTime gameTime)
    {
        // Your game logic here
        base.Update(gameTime);
    }

    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);

        // Your drawing code here

        base.Draw(gameTime);
    }
}

2. Add the Namespace to Your Avalonia View

<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:monoGame="clr-namespace:AvaloniaInside.MonoGame;assembly=AvaloniaInside.MonoGame"
             x:Class="YourNamespace.YourView">

    <monoGame:MonoGameControl Game="{Binding CurrentGame}" />

</UserControl>

3. Set Up Your ViewModel

public class MainViewModel : ViewModelBase
{
    public Game CurrentGame { get; set; } = new MyExampleGame();
}

MonoGame running in Avalonia

📚 Examples

Check out the example project in this repository for comprehensive usage examples including:

  • Basic MonoGame integration
  • Auto-playing Pong game
  • Input handling patterns
  • Content loading and management

🔧 Advanced Usage

Resolution-Independent Rendering

Use the ResolutionRenderer class for resolution-independent rendering:

public class MyGame : Game
{
    private ResolutionRenderer _resolutionRenderer;

    protected override void Initialize()
    {
        _resolutionRenderer = new ResolutionRenderer(
            this,
            new Point(1920, 1080), // Virtual resolution
            new Point(1920, 1080)  // Actual resolution
        );

        base.Initialize();
    }

    protected override void Draw(GameTime gameTime)
    {
        _resolutionRenderer.BeginDraw();

        // Your drawing code here

        base.Draw(gameTime);
    }
}

⚠️ Known Issues

  1. Mobile platforms - Not currently supported (iOS, Android)
  2. Input handling - Device input should be managed through native Avalonia input system rather than MonoGame's input
  3. Performance - Performance optimizations are ongoing; may not be optimal for all scenarios yet

🤝 Contributing

Contributions are welcome! Please feel free to submit issues, fork the repository, and create pull requests.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤️ by the AvaloniaInside team

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 574 11/21/2025
1.0.1 876 7/8/2023
1.0.0 413 1/7/2023

MonoGame integration control for Avalonia UI