Adding PC Ads to a Page

The preceding text file, although overly verbose, demonstrates that you use an instance of Microsoft.Advertising.WinRT.UI.AdControl to display an ad to the user. You just need to give it the ApplicationId for your app (the GUID visible on the pubCenter website) and the AdUnitId for the relevant ad unit (also visible on the pubCenter website). The following XAML is a cleaned-up version of the two AdControls, used with a more appropriate XML namespace, and added to the Blank App project’s MainPage.xaml file:

<Page x:Class="Chapter8.MainPage"   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   xmlns:pubCenter="using:Microsoft.Advertising.WinRT.UI" ...

Get Universal Windows® Apps with XAML and C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.