I had to search around for this information so I thought it would be nice to have it somewhere handy. Here’s the scenario: You want to put ads into your Windows Phone app, but only when it is in trial mode.
I decided that the best way to do this was to create a Grid layout with 2 rows. The top row is for all the important stuff in my app and the bottom row is holding my AdControl. The XAML looks something like this:
<Grid x:Name="LayoutRoot" >
<!-- all my UI goes here -->
<Border x:Name="AdControlHolder" Grid.Row="1">
If I don’t place anything in my Border control, it will be completely invisible. So what we’re going to do is:
The only problem with this is that it can be difficult to test. For one thing, the AdControl requires some custom parameters to run in a test environment. Additionally, we can’t set the app to “trial mode” in the test environment, so we have to simulate it. I’ve tried to take all this and encapsulate it in a block of code.
LicenseInformation info = new LicenseInformation();
if ( info.IsTrial() )
// running in trial mode
AdControl ac = new AdControl();
ac.AdUnitId = "Image480_80";
// or for text ads
//ac.AdUnitId = "TextAd";
// or for smaller ads
//ac.AdUnitId = "Image300_50";
ac.ApplicationId = "test_client";
#else ac.AdUnitId = "000000"; // insert your AdUnitId from the pubCenter site
// add your ApplicationId from the pubCenter ac.ApplicationId = "12345678-1234-1234-1234-123456789012";
ac.Width = 480;
ac.Height = 80;
AdControlHolder.Child = ac;
And that should be good to get started!