Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

AdControl Class

Updated: March 31, 2014

Published: April 2, 2014

Provides the information needed to show advertising in your application.

Namespace: Microsoft.Advertising.Mobile.UI

Assembly: Microsoft.Advertising.Mobile.UI (in Microsoft.Advertising.Mobile.UI.dll)

public class AdControl :  UserControl

When the AdControl is created, the rotationEnabled parameter is set to true. The AdControl will then show a new ad every 30 to 60 seconds.

If this behavior does not suit the application, you can instantiate the AdControl with automatic ad rotation deactivated. To do this, call the overloaded constructor with the IsAutoRefreshEnabled parameter set to false. You can then use the Refresh method to show the next ad.

Use one or more unique instances of an AdControl on a page. Do not use the same instance of an AdControl across multiple pages.

Once set, the parent of an AdControl should not be changed.

All required properties of the AdControl need to be set when it is instantiated.

If the code can show a test ad in the emulator but no new ad is shown on a device, an error may have occurred in transmission or no new ad may be available. Use the ErrorOccurred event to help determine the cause.

Example

The following markup uses the Silverlight framework and is an example of instantiating a new AdControl. Note: You must set the AdUnitId property before you can show an ad.

<Grid x:Name="ContentPanel" Grid.Row="1">

  <UI:AdControl 
         ApplicationId="test_client" 
         AdUnitId="Image480_80" 
         HorizontalAlignment="Left" 
         Height="80" 
         VerticalAlignment="Top" 
         Width="480"/>

</Grid>

Example

The following markup uses the XAML framework and is an example of instantiating a new AdControl. Note: You must set the AdUnitId property before you can show an ad.

<Grid x:Name="ContentPanel" Grid.Row="1">

  <UI:AdControl 
         ApplicationId="test_client" 
         AdUnitId="Image320_50" 
         HorizontalAlignment="Left" 
         Height="50" 
         VerticalAlignment="Top" 
         Width="320"/>

</Grid>

Example

You can use markup to set the ad refresh to manual.

IsAutoRefreshEnabled = false

Inheritance Hierarchy

Object :: DependencyObject :: UIElement :: FrameworkElement :: Control :: UserControl :: Microsoft.Advertising.Mobile.UI.AdControl

Support and Feedback

Get product support or report a bug in the product by visiting the Windows Phone Dev Center support page (scroll down to the section "Microsoft Advertising support").

Send feedback about this documentation to adsfdbk@microsoft.com. There is no product support through this alias. Documentation feedback only.

Community Additions

ADD
Show:
© 2015 Microsoft