0

当手机处于横向模式时,我的应用程序中没有足够的屏幕空间来显示 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 吗?

4

1 回答 1

1

这是一个新的解决方案,当手机方向更改为横向时,允许广告控件保持静止。它使用了一个新控件,即使在旋转时(横向时向左或向右),广告控件也能保持在“底部”。

10 秒的概述是创建一个网格布局并将 AdControl 移动到适用于方向的行/列组合。该博客包含所有详细信息。

于 2013-10-28T07:51:26.930 回答