根据应用状态启用/停用广告

时间:2012-11-05 15:16:40

标签: windows visual-studio-2010 windows-phone-7

我希望在我的应用获得试用时展示我的广告,并在应用获得完全许可时消失。

Kookiz -

Private Sub PhoneApplicationPage_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs)

    If App.IsTrial Then
        AdControl1.Visibility = Windows.Visibility.Visible

    Else
        AdControl1.Visibility = Windows.Visibility.Collapsed
    End If

End Sub

1 个答案:

答案 0 :(得分:1)

问题是IsEnabled仍显示控件。

您应该做的是在XAML文件中为广告添加一个空容器,如下所示:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>            
    <StackPanel x:Name="spAd" Grid.Row="0">
        <!--Ad will be placed here via the code-->
    </StackPanel>   
</Grid>

然后在PhoneApplicationPage_Loaded事件处理程序中,如果IsTrial等于true,则将AdControl实例化并将其添加到视图中:

AdControl _adControl = new AdControl();

// Use your real Application ID and Ad Unit ID here
_adControl.ApplicationId = "test_client";
_adControl.AdUnitId = "Image480_80"; 

_adControl.Width = 480;
_adControl.Height = 80;

spAd.Children.Add(_adControl);