问题是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);