AvaloniaInside.MonoGame
1.0.2
dotnet add package AvaloniaInside.MonoGame --version 1.0.2
NuGet\Install-Package AvaloniaInside.MonoGame -Version 1.0.2
<PackageReference Include="AvaloniaInside.MonoGame" Version="1.0.2" />
<PackageVersion Include="AvaloniaInside.MonoGame" Version="1.0.2" />
<PackageReference Include="AvaloniaInside.MonoGame" />
paket add AvaloniaInside.MonoGame --version 1.0.2
#r "nuget: AvaloniaInside.MonoGame, 1.0.2"
#:package AvaloniaInside.MonoGame@1.0.2
#addin nuget:?package=AvaloniaInside.MonoGame&version=1.0.2
#tool nuget:?package=AvaloniaInside.MonoGame&version=1.0.2
AvaloniaInside.MonoGame
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
ResolutionRendererfor 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();
}

📚 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
- Mobile platforms - Not currently supported (iOS, Android)
- Input handling - Device input should be managed through native Avalonia input system rather than MonoGame's input
- 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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🔗 Links
Made with ❤️ by the AvaloniaInside team
| Product | Versions 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. |
-
net10.0
- Avalonia (>= 11.3.9)
- MonoGame.Framework.DesktopGL (>= 3.8.4.1)
-
net8.0
- Avalonia (>= 11.3.9)
- MonoGame.Framework.DesktopGL (>= 3.8.4.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
MonoGame integration control for Avalonia UI