Hello,
In my last Apps with MonoGame i simply could write xaml code in the GamePage.xaml and it was displayed above the MonoGame Stuff. <- This was easy and I liked it.
But here is my problem: XAML doesn’t show up anymore. Even if I create a new WP8.1 project and simply add a button to the grid from the GamePage.xaml nothing is visible.
Please tell me where I should put my xaml code?
I’m using latest MonoGame dev build (3.3) … vs2013 with all updates … lumia 1020
Edit: This is the GamePage.xaml
Edit2: I tried everything. Xaml code is definitely not shown in the GamePage.xaml file. But where should I put the xaml code ?!?
Ok, I spend several days wasting my time to get it to work. So please tell me where to put my XAML code, this can’t be that difficult, otherwise MonoGame is heading in a completely wrong direction.
Example: I want to display a <Button /> … where do I have to put this code so that I can see the button on my phone?
Thanks for you reply : )
Are you on the development branch version 3.3?
If I create a new WP8.1 Monogame project, there is no <Phone:PhoneApplicationPage ...
Only the App.xaml and the MainPage.xaml which is only a SwapChainBackgroundPanel and not a DrawingSurfaceBackgroundGrid.
<SwapChainBackgroundPanel
x:Class="Game2.GamePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Game2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<Button Content="I can't see this button"/>
</Grid>
</SwapChainBackgroundPanel>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using MonoGame.Framework;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkID=390556
namespace Game2
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class GamePage : SwapChainBackgroundPanel
{
readonly Game1 _game;
public GamePage()
{
this.InitializeComponent();
}
public GamePage(string launchArguments)
{
_game = XamlGame<Game1>.Create(launchArguments, Window.Current.CoreWindow, this);
}
}
}
Simply create a new WP8.1 Monogame 3.3 Template Project and try to add xaml code. I found no way my xaml code is visible.
This is something I saw a few days ago and I thought it was weird. There are two constructors, one calls InitializeComponent and the other one does not. Could you check which one is being called, and putting InitializeComponent before Create if it’s the second one?
Yeah, simply add this.InitializeComponent(); to the second constructor and everything works fine.
… so someone should fix the template.
public sealed partial class GamePage : SwapChainBackgroundPanel
{
readonly Game1 _game;
public GamePage() //Constructor is never called
{
this.InitializeComponent();
}
public GamePage(string launchArguments)
{
// Here was a InitializeComponent missing.
this.InitializeComponent();
_game = XamlGame<Game1>.Create(launchArguments, Window.Current.CoreWindow, this);
}
}
}
I don’t know if this is a bug or a feature, the one who built two constructors probably had a good reason to do so (I don’t know, maybe performance reasons?)