Question

I am looking to making a multi-paged WindowsPhone 8 app that features an AdControl at the bottom. Now what I am interested in is to find out if there's a possibility of putting the AdControl in a separate frame of sorts so that the page navigation doesn't interfere with it. Basically I'm trying to split the app ViewPort into 2 parts: the app and the AdControl.

The AdControl should always be on and there would be no need to add it to different pages and to refresh it each time a navigation is performed.

Can something like this be done?

Was it helpful?

Solution

You can accomplish this by setting the style of the PhoneApplicationFrame. In the App.xaml, add the following resource

<Style x:Key="AdPhoneApplicationFrameStyle" TargetType="phone:PhoneApplicationFrame">
    <Setter Property="IsTabStop" Value="False"/>
    <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
    <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeNormal}"/>
    <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
    <Setter Property="HorizontalAlignment" Value="Stretch"/>
    <Setter Property="VerticalAlignment" Value="Stretch"/>
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    <Setter Property="VerticalContentAlignment" Value="Stretch"/>
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="BorderThickness" Value="0"/>
    <Setter Property="BorderBrush" Value="{x:Null}"/>
    <Setter Property="Padding" Value="0"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="phone:PhoneApplicationFrame">
                <Border x:Name="ClientArea" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            <adDuplex:AdControl Grid.Row="1"/>
                    </Grid>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

In App.xaml.cs within the InitializePhoneApplication add the following line after the RootFrame is created

RootFrame.Style = (Style)Resources["AdPhoneApplicationFrameStyle"];

If you want to have page transitions, see this blog post for more information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top