0

I want to add an adunit to the TopAppBar of the page.

    <Page.TopAppBar>
        <AppBar IsOpen="True">
        <UI:AdControl 
          AutoRefreshIntervalInSeconds="60" 
          ApplicationId="be1500d6-9ca7-4a0b-a479-0db279d71e14" 
          AdUnitId="11191335" 
          HorizontalAlignment="Center" 
          IsAutoRefreshEnabled="True" 
          VerticalAlignment="Top" 
          Width="320"
          Height="50" IsAutoCollapseEnabled="True"
          />
        </AppBar>
    </Page.TopAppBar>

This compiles and runs without error but after adding this to my code, the Frame.Navigate to this page is returning a false value. How to correct it so that Navigation is successful? If this is not the right way then how can I make my ad stay on the top of the page always even on scrolling.

Nikhil Gupta
  • 172
  • 1
  • 18

1 Answers1

0

Windows Phone doesn't support a top AppBar. If you want to show your add at the top of the page then put it in a row of a Grid at the top of the page. Put the page content you want to scroll in a second row underneath it. Something like:

<Grid>
    <Grid.RowDefinitions>
         <RowDefinition Height="50"/>
         <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <UI:AdControl Grid.Row="0" />
    <GridView Grid.Row="1" /> <!-- or whatever else you want for the page content -->
</Grid>
Rob Caplan - MSFT
  • 21,714
  • 3
  • 32
  • 54
  • I previously tried this. I placed the ad in Grid.Row="0" and then a StackPanel in Grid.Row="1". Inside the StackPanel, I placed a ScrollViewer and my content within that. The page was opening then but I wasn't able to scroll. How to make it scrollable? – Nikhil Gupta Feb 02 '15 at 19:06
  • That's a different question but get rid of the StackPanel. The StackPanel will grow however large it needs to be to fit its contents. Because the whole ScrollViewer will fit in the stack it doesn't need to scroll. The ScrollViewer needs to be in a limited size container. – Rob Caplan - MSFT Feb 02 '15 at 19:24
  • Then please tell how to place my content in Grid.Row="1" so that only that row is scrollable and the adcontrol stays at the top. I'll definitely need to make my content in Row 1 scrollable because it's too large to fit in the screen. – Nikhil Gupta Feb 02 '15 at 19:29
  • Get rid of the StackPanel and put the ScrollViewer directly in the row. – Rob Caplan - MSFT Feb 02 '15 at 19:31
  • What if my StackPanel had many elements within it. Then, I can't remove the it since the ScrollViewer can have only 1 element. – Nikhil Gupta Feb 07 '15 at 07:13
  • I tried putting the StackPanel inside a Grid with 1 row of height="*" and then enclosing the Grid within the ScrollViewer. That didn't work either. – Nikhil Gupta Feb 07 '15 at 07:15