Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

AdControl class

Represents a control that displays banner ads in a Windows Phone Silverlight app.

Syntax

public class AdControl :  System.Windows.Controls.Control

Members

The AdControl class has these constructors.

ConstructorDescription
AdControl Instantiates a new AdControl.

 

The AdControl class has these events.

EventDescription
AdRefreshed Raised when the AdControl receives a new ad.
ErrorOccurred Raised when the AdControl encounters an error.
IsEngagedChanged Raised when the user clicks the ad and the action dialog box appears.

 

The AdControl class has these methods.

MethodDescription
Refresh Directs the AdControl to show the next ad when a new one becomes available, if auto-refresh is disabled. The currently rendered ad remains until the next ad becomes available.
Resume Resumes the normal display of a banner ad after a call to Suspend.
Suspend Suspends the current banner ad and replaces the current view of the ad with a static snapshot of what was being rendered.
Suspend(bool) Suspends the current banner ad and replaces the current view of the ad with a static snapshot of what was being rendered. This overload allows the ad to be placed in a suspended state while canceling any expanded experience or without closing a full screen ad.

 

The AdControl class has these properties.

PropertyAccess typeDescription
AdUnitId Read/writeGets or sets the ad unit ID for this AdControl object.
ApplicationId Read/writeGets or sets the application ID for this AdControl object.
AutoRefreshIntervalInSeconds Read/writeGets or sets the interval at which the AdControl refreshes the currently displayed banner ad, in seconds.
CountryOrRegion Read/writeGets or sets the user’s two-letter country or region code.
HasAd Read-onlyGets a value that indicates whether or not the AdControl is currently serving a banner ad.
IsAutoCollapseEnabled Read/writeGets or sets the value that indicates whether the AdControl will automatically hide itself if no ad is available or an error occurs.
IsAutoRefreshEnabled Read/writeGets or sets a value that indicates whether automatic rotation of banner ads is enabled.
IsBackgroundTransparent Read/writeGets or sets a value that indicates whether the background of the AdControl is transparent.
IsEngaged Read-onlyGets a value that indicates whether the user is interacting with the banner ad.
IsSuspended Read-onlyGets a value that shows whether the AdControl is in a suspended state.
Keywords Read/writeGets or sets the keywords that target the audience for advertisements.
Latitude Read/writeGets or sets the current latitude to use for targeting advertisements.
Longitude Read/writeGets or sets the current longitude to use for targeting advertisements.
PostalCode Read/writeGets or sets the postal code to use for targeting advertisements.

 

Remarks

This class is available via the Microsoft Store Advertising SDK for Windows and Windows Phone 8.x. For more information, see AdControl in Windows Phone Silverlight.

By default, an AdControl is configured to show a new ad every 60 seconds. If you want to change this behavior, you can instantiate the AdControl with automatic ad rotation deactivated. To do this, set the IsAutoRefreshEnabled property false and 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. 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 demonstrates how to instantiate a new AdControl. 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>

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

IsAutoRefreshEnabled = false

Requirements

Minimum supported phoneWindows Phone 8 Silverlight
Namespace Microsoft.Advertising.Mobile.UI
AssemblyMicrosoft.Advertising.Mobile.UI.dll

 

 

 

Show: