Wpf Monogame Interop wont load in Designer

338 views Asked by At

Hi im using the WpfInterop NuGet Plugin from this Location https://gitlab.com/MarcStan/MonoGame.Framework.WpfInterop/ I did everything the way it is in the readme file but itjust wont load in my designer.

It always says "An Instance of "Game1" could not be created (translated from german)" and wont compile either.

I Already tried a new Project but still the same result. Using other windows does not work either, even generating a new Game class wont help.

My XAML file:

<Window x:Class="MapEditor.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:MapEditor"
    mc:Ignorable="d"
    Title="MainWindow" Height="479.369" Width="767.693" WindowStartupLocation="CenterScreen">
<Grid Margin="0,0,2,-1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
    <Grid.BindingGroup>
        <BindingGroup/>
    </Grid.BindingGroup>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="377*"/>
        <ColumnDefinition Width="0*"/>
        <ColumnDefinition/>
        <ColumnDefinition Width="380*"/>
    </Grid.ColumnDefinitions>

    <Menu Height="21" VerticalAlignment="Top" Grid.ColumnSpan="4" Grid.IsSharedSizeScope="True" Foreground="Black">
        <Menu.Background>
            <SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlColorKey}}"/>
        </Menu.Background>
        <MenuItem Height="21" Width="45" AllowDrop="True" Header="Datei" >
            <MenuItem Header="Test"/>
        </MenuItem>
        <MenuItem Header="Bearbeiten" Width="72"/>
    </Menu>
    <ListView HorizontalAlignment="Left" Margin="10,26,0,10" Width="165">
        <ListView.View>
            <GridView>
                <GridViewColumn/>
            </GridView>
        </ListView.View>
    </ListView>
    <ListView Margin="0,26,10,10" Grid.Column="3" HorizontalAlignment="Right" Width="165">
        <ListView.View>
            <GridView>
                <GridViewColumn/>
            </GridView>
        </ListView.View>
    </ListView>
    <local:Game1 Width="50" Height="50"/>
</Grid>

Edit: my Game1 Class

using MapEditor.mapClasses;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Framework.WpfInterop;
using MonoGame.Framework.WpfInterop.Input;


namespace MapEditor
{
/// <summary>
/// This is the main type for your game.
/// </summary>
/// 

public class Game1 : WpfGame
{

    private IGraphicsDeviceService _graphicsDeviceManager;
    private WpfKeyboard _keyboard;
    private WpfMouse _mouse;

    protected override void Initialize()
    {
        // must be initialized. required by Content loading and rendering (will add itself to the Services)
        _graphicsDeviceManager = new WpfGraphicsDeviceService(this);

        // wpf and keyboard need reference to the host control in order to receive input
        // this means every WpfGame control will have it's own keyboard & mouse manager which will only react if the mouse is in the control
        _keyboard = new WpfKeyboard(this);
        _mouse = new WpfMouse(this);

        // must be called after the WpfGraphicsDeviceService instance was created
        base.Initialize();

        // content loading now possible
    }

    protected override void Update(GameTime time)
    {
        // every update we can now query the keyboard & mouse for our WpfGame
        var mouseState = _mouse.GetState();
        var keyboardState = _keyboard.GetState();
    }

    protected override void Draw(GameTime time)
    {
    }
  }
}
0

There are 0 answers