The Microsoft Advertising SDK for Windows 8 allows developers to show ads in their apps. When you look at the walkthrough for putting ads in an app using XAML/C#, you can see that you have to set the ApplicationId and AdUnitId property of each AdControl control in your app. The AdUnitId can only be set when the AdControl is instantiated using the default constructor. This sample application shows a way on how to set the AdUnitId during runtime.
For testing purposes, Microsoft has defined an ApplicationId and several AdUnitId. These values are required in case you have no ids created in the pubCenter for yourself or in case you want to test your app in the emulator.
Having the AdControl defined in XAML using these test values, you cannot change them later on during runtime to your production values. Means, you have to have two different XAML versions: one for testing purposes and one for production.
This sample application shows a way on how to avoid this. It offers an approach on how to set the AdUnitId during runtime. This makes it easy to configure the ids in a config file, switch between test and production values without always have to change the XAML.
The app contains the zipped sample code, so you do not need to download it separately from a web page.