Skip to content

Getting Started

Fabian Nawratil edited this page Apr 19, 2016 · 3 revisions

Referencing MonogameUI

MonogameUI will probably be available on NuGet, until then you will have to compile it yourself and include the DLL everywhere you need it

Creating a ScreenManager

To display any Screens you will need a ScreenManager. It will take care of Navigation and provide a basic Frame in which our Pages get rendered.

First create a new Class and make it inherit from "BaseScreenComponent". Create the basic Constructor and override the Method LoadContent(). This Method gets called when your ScreenManager initializes and allows you to e.g. set Animations, Skins or navigate to the first Screen. For now the following will suffice:

public class ScreenComponent : BaseScreenComponent
{
    public ScreenComponent(Game game) : base(game){}

    protected override void LoadContent()
    {
        base.LoadContent();
        Frame.Background = new BorderBrush(Color.CornflowerBlue); //Here we set a Background Color.
    }
}

The first Screen

To display any Controls you will need a Screen on which they are positioned. All Controls will be positioned relative to their parent. This means that Screens will be positioned relative to the Window, "First Level" Controls relative to the Screen and so on.

To create your first Screen create a class which inherits from the MonogameUI "Screen" class. The base Constructor takes one Argument: an IScreenManager Object.

public class MyScreen : Screen
{
    public MyScreen(IScreenManager manager) : base(manager) {}
}