MonoGame XAML Support

Dec 4, 2012 at 10:15 AM

Hi, 

any plans to support MonoGame XAML Templates ?

I'm using pubCenter and AdDuplex, both are working in the XAML Templates. 

But Ad Rotator does not work (is not displayed).

 

The Idea behin this : 

Having a XNA Game (Mono) for windows 8 and a XAML SwapChainBackgroundPanel infromt of it.

Coordinator
Dec 4, 2012 at 10:53 AM

The Windows 8 version of AdRotator should work like any other XAML component in a MonoGame XAML project.  Haven't tested in that scenario but i'll check and get back to you.  It's just a UserControl so there shouldn't be any reason it shouldn't work.

The desktop MonoGame template wouldn't work at the moment obviously, that would have to use the MonoGame specific version which is only available in V1 at the moment (untested with MonoGame Desktop on Win 8)

Dec 4, 2012 at 12:11 PM
Edited Dec 4, 2012 at 12:20 PM

I've installed AdRotator via 

PM> Install-Package AdRotatorWin8

so i got Version 1.0.7.

 

This is the code i use in my "GamePage.xaml"

<AdRotatorWin8:AdRotatorControl x:Name="AdRotatorWin8"
                                        AdHeight="130"
                                        AdWidth="500"                                       
                                        DefaultSettingsFileUri="defaultAdSettings.xml"
                                        SettingsUrl="http://www.podkowik.net/settings.xml" 
                                        IsTest="true"/>

My defaultAddSettings.xml

<?xml version="1.0" encoding="utf-8"?>
<AdSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<CultureDescriptors>
		<AdCultureDescriptor CultureName="default">
      <Probabilities Probability="80" AdType="PubCenter" AppID="3a13517c-938a-4ea0-a1fb-72efed0190d3" SecondaryID="105788" />
      <Probabilities Probability="20" AdType="AdDuplex" AppID="26907"/>
    </AdCultureDescriptor>
	</CultureDescriptors>
</AdSettings>

The Remote Settings file is still online, so you can check. But i see nothing :/

If i try it with the adduplex or pubcenter controll, everything works fine

 <!--
        <adduplex:AdControl x:Name="ad" 
                    AppId="26907"                             
                    VerticalAlignment="Top"
                    HorizontalAlignment="Left"
                    Visibility="Collapsed"
                    Size="500x130"
                    />
     
        <UI:AdControl 
            ApplicationId="3a13517c-938a-4ea0-a1fb-72efed0190d3" 
            AdUnitId="105788" 
            HorizontalAlignment="Left" 
            Height="130" 
            Name="AddComponent"
            Margin="0,0,0,0" 
            VerticalAlignment="Top"            
            Width="500"/>
 -->

 

// Edit : i've tried the setting.xml and defaultAdSettings.xml in the AdRotatorExampleWin8 and everything works well.

// Edit : I also tried to put the AdRotatorWin8:AdRotatorControl inside a Border like in the examples. Now i see the border but no ads :/

Coordinator
Dec 4, 2012 at 12:51 PM

Just tested in a fresh MonoGame project and using your config above it's working.

 

Have you completed all the steps from the instructions including calling "AdRotatorWin8.Invalidate();" in your CodeBehind in the "Loaded" Event?

        public GamePage(string launchArguments)
        {
            this.InitializeComponent();

            // Create the game.
            _game = XamlGame<Game1>.Create(launchArguments, Window.Current.CoreWindow, this);

            Loaded += GamePage_Loaded;
        }

        void GamePage_Loaded(object sender, RoutedEventArgs e)
        {
            AdRotatorWin8.Invalidate();
        }

If you don't call "Invalidate", AdRotator won't start fetching Ads.

Putting the AdRotator control in a Border shouldn't stop it from generating Ads, also if you intend to use the control in multiple pages we recommend putting it in your own user control and reusing that rather than fresh instances on each page.

Dec 4, 2012 at 2:59 PM

No, i have not called AdRotatorWin8.Invalidate();

I'm sure this will fix my Problem (willl check it later, have to do some stuff in linux and don't want to reboot now)

You should add this IMPORTANT info MORE present here 

http://wp7adrotator.codeplex.com/wikipage?title=AdRotator%20Usage%20Windows%208

I've found this sentence (after reading it again) : Then call the "Invalidate" function from your code behind, for best results we suggest doing this in the "Loaded" event handler....

But this really important info somehow gets lost in the text ;)

I have to admit that i only read the "Code" Part of this docu the first time. Maybe you should add this

void GamePage_Loaded(object sender, RoutedEventArgs e)
        {
            AdRotatorWin8.Invalidate();
        }

 

as a Code part too.

Anyway: Thank you for your help and sorry you had to waste so much time on this :)

Coordinator
Dec 4, 2012 at 3:18 PM

Fair point, I do go into more detail in the tutorial if you follow the link at the bottom of the documentation.

But I will add your comments to the page, thanks.

Dec 4, 2012 at 4:04 PM

AdRotatorWin8.Invalidate(); solved my problem :) 

Now everything is ready and i can submit my game to the marketplace (OK i still need a Splashscreen, icons and screenshots, so tomorrow will be submission day ! ) :)

Coordinator
Dec 11, 2012 at 11:40 AM

Windows 8 NuGet package updated, check it out and let me know