当手机处于横向模式时,我的应用程序中没有足够的屏幕空间来显示 AdControl。我在我的OnOrientationChanged
事件处理程序中使用以下(简化)代码在进入横向模式时从网格的第 1 行删除 AdControl,并在进入纵向模式时将其添加回来:
if (this.Orientation == PageOrientation.LandscapeLeft ||
this.Orientation == PageOrientation.LandscapeRight) {
LayoutRoot.Children.Remove(myAdControl);
LayoutRoot.RowDefinitions.RemoveAt(1);// remove row to make space
} else {
LayoutRoot.RowDefinitions.Add(adRow);// previously constructed 80 px high RowDefinition
LayoutRoot.Children.Add(myAdControl);
Grid.SetRow(myAdControl, 1);
}
这似乎在我的测试中有效,但我在 AdControl 类的文档中看到“一旦设置,不应更改 AdControl 的父级”。我在这里所做的会破坏 AdControl 吗?