Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 8 ads showing up on top of settings flyout

First, a screenshot:

ad from main view showing up on settings flyout

The title and image explain it pretty well. I have an ad set on the right side of my app's main group view (very very similar to the default grid template in this example), and when I pull up my About screen, the ad bleeds through.

The About screen is a user control set on a SettingsFlyout that I borrowed from some code samples handed out at a dev-camp (below).

class SettingsFlyout
{
    private const int _width = 346;
    private Popup _popup;

    public void ShowFlyout(UserControl control)
    {
        _popup = new Popup();
        _popup.Closed += OnPopupClosed;
        Window.Current.Activated += OnWindowActivated;
        _popup.IsLightDismissEnabled = true;
        _popup.Width = _width;
        _popup.Height = Window.Current.Bounds.Height;

        control.Width = _width;
        control.Height = Window.Current.Bounds.Height;

        _popup.Child = control;
        _popup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - _width);
        _popup.SetValue(Canvas.TopProperty, 0);
        _popup.IsOpen = true;
    }

    private void OnWindowActivated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)
    {
        if (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.Deactivated)
        {
            _popup.IsOpen = false;
        }
    }

    void OnPopupClosed(object sender, object e)
    {
        Window.Current.Activated -= OnWindowActivated;
    }
}

And, because I know it will be asked for, here is the line of XAML defining the ad on my page:

<ads:AdControl Visibility="{Binding IsTrial, Source={StaticResource License}, Converter={StaticResource BooleanToVisibilityConverter}}"  Grid.Row="0" Grid.RowSpan="2" x:Name="LandscapeAdControl" ApplicationId="test_client" AdUnitId="Image_160x600" Width="160" Height="600" VerticalAlignment="Center" HorizontalAlignment="Right"/>

So, why is this happening, and how do I prevent it?

Suspicions

  1. I am still on Consumer Preview b/c I have a show-and-tell Monday and didn't have time to work on migrating the OS on this box without risking being non-functional when I am showing this. As such, upgrading might fix it if it's a bug.

    1.a. Update I have upgraded to Release Preview and have the same issue.

  2. Is there some fancy ad-hiding-but-still-getting-impressions prevention technique at play here? Perhaps it thinks I am trying to cover the ad with a ui element and still get credit for it's impression without the user seeing it. If so, how do I manage this entirely legit use case?

Spoiler Alert: ZIndex isn't set anywhere.

like image 468
Andy_Vulhop Avatar asked Nov 04 '22 22:11

Andy_Vulhop


1 Answers

It presents the same problem with overlaying the AppBar (top or bottom). I used the Opened and Closed events on the AppBar instance to hide/show the ad. This means the AdControl is bound to a local page property instead of binding directly to a ViewModel. Like you said, it's unfortunate but it works.

    private void bottomAppBar_Opened(object sender, object e)
    {
        if (App.ViewModel.IsTrialVisibility == Visibility.Visible)
            this.DefaultViewModel["AdVisibility"] = Visibility.Collapsed;
        // else do nothing as we don't want to show it since it's not a trial
    }

    private void bottomAppBar_Closed(object sender, object e)
    {
        if(App.ViewModel.IsTrialVisibility == Visibility.Visible)
            this.DefaultViewModel["AdVisibility"] = Visibility.Visible;
        // else do nothing as it's not shown in the first place (not a trial)
    }
like image 145
Ray Ackley Avatar answered Dec 05 '22 22:12

Ray Ackley