Wpf Monogame Interop не загружается в Designer

Привет, я использую плагин WpfInterop NuGet из этого местоположения https://gitlab.com/MarcStan/MonoGame.Framework.WpfInterop/ Я сделал все так, как в файле readme, но он просто не загружается в моем конструкторе.

Он всегда говорит "Экземпляр"Game1"не может быть создан (перевод с немецкого)" и не компилируется.

Я уже пробовал новый проект, но все тот же результат. Использование других окон также не работает, даже генерация нового класса Game не поможет.

Мой XAML-файл:

<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>

Изменить: мой класс Game1

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 ответов

Другие вопросы по тегам