0

我希望我的广告在我的应用程序试用期间展示,并在应用程序获得完全许可后消失。

库克兹-

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
4

1 回答 1

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);
于 2012-11-05T15:25:34.367 回答