Collapse control if no ad loaded at all?

Apr 14, 2012 at 8:45 AM

I've started testing my app in flight mode to make sure that it doesn't break if there isn't any network connectivity. I've noticed that the ad control is still on the page even if no ad is showing. This is seen most clearly in my app if there is more content to scroll than would fit on the screen.

Would it be possible for the control to automatically collapse if no ad is loaded, or do you suggest that I hook onto an event and programmatically set the visibility to collapsed if no ad loads?




Apr 14, 2012 at 8:48 AM

Just as an update to this question, one of the challenges I'm seeing here is that the white border for the control briefly appears then vanishes. Ideally I'd like to try and eliminate that but I don't know how best to achieve it, or indeed if it is something that I can resolve myself.




Apr 14, 2012 at 10:31 AM

The UnifiedAdControl is in its sense a ContentControl which has one or none AdControls as content. Most of the AdProviders don't give a NoAd message before being shown first.

Something that can be done is Check if there's Network connectivity and set the Visibility of the adcontrol to Collapsed in case of no visibility.

If you give the UnifiedAdControl a name like "Ad". You can use this code inside the OnNavigatedTo methods of the pages.

if (!NetworkInterface.GetIsNetworkAvailable() || NetworkInterface.NetworkInterfaceType == NetworkInterfaceType.None)
    Ad.Visibility = Visibility.Collapsed;
    Ad.Visibility = Visibility.Visible;

Apr 15, 2012 at 8:37 AM

Will the solution above be implemented in a future version of the control?

Apr 15, 2012 at 12:46 PM

Do you want a solution like above to be implemented in UnifiedAd? I am wondering if this is something you would always want, or if there are situations where you would want to try to show ads, even without connectivity. Probably it's a good approach to hide the ad when no connectivity is present. I will create a workitem.

Apr 15, 2012 at 1:14 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.