views:

48

answers:

1

Hi everyone! I was messing around with this windows phone 7 application bar when I noticed that even setting a different application bar in XAML wouldn't make it change through different application pages (which is quite annoying I have to say). My intention is to use this bar with some buttons that change according to the page being displayed, let's say, in the main menu, it won't show the main menu icon, but in another page it will. Can you guys provide me some help?

Page 1:

<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBar.Buttons>
                <shell:ApplicationBarIconButton IconUri="Icons/mainmenu.png" Text="Main Menu"  />
                <shell:ApplicationBarIconButton IconUri="Icons/list.png" Text="Comic List"  />
                <shell:ApplicationBarIconButton IconUri="Icons/settings.png" Text="Settings"  IsEnabled="True" x:Name="ApplicationBarUploadIconButton" />
            </shell:ApplicationBar.Buttons>

        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

Page 2:

<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBar.Buttons>
                <shell:ApplicationBarIconButton IconUri="Icons/settings.png" Text="Settings"  />
                <shell:ApplicationBarIconButton IconUri="Icons/list.png" Text="Comic List"  />
                <shell:ApplicationBarIconButton IconUri="Icons/download.png" Text="Download Comic"  IsEnabled="True" x:Name="ApplicationBarUploadIconButton" />
            </shell:ApplicationBar.Buttons>

        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

Page 3:

 <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="False" IsMenuEnabled="False">
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

The application bar is always the same and is always displayed (even with that explicit declaration in page 3 not to show it).

Thanks in advance!

A: 

Hi Bruno,

You can indeed have different number of buttons in the application bar across various pages. If you have added an application bar to a page and see 4 empty rounded areas in every page, nothing to worry about - it is only the designer view. As an example, in your MainPage.xaml, you can have an application bar like so -

<phone:PhoneApplicationPage.ApplicationBar>
  <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
     <shell:ApplicationBarIconButton IconUri="/Images/appbar.refresh.rest.png" 
                                     Text="Refresh"
                                     Click="RefreshPage_Click" />
  </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

In the DetailsPage.xaml page, you can have an application bar like so -

<phone:PhoneApplicationPage.ApplicationBar>
  <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
     <shell:ApplicationBarIconButton IconUri="/Images/appbar.home.png" 
                                     Text="Home"
                                     Click="GoBackHome_Click" />
     <shell:ApplicationBarIconButton IconUri="/Images/appbar.next.rest.png" 
                                     Text="Next"
                                     Click="NextPage_Click" />
     <shell:ApplicationBarIconButton IconUri="/Images/appbar.previous.rest.png" 
                                     Text="Next"
                                     Click="PreviousPage_Click" />
  </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

HTH, indyfromoz

indyfromoz
I did it, but in the emulator all the buttons look exactly the same and have the same caption.
Bruno
So, are you seeing buttons with no icons? How many pages have you got in your application? It will help if you posted some XAML from your app. The examples in my reply are copied from an application I have built and it works fine on the emulator and the real hardware. One gotcha is to set the Build Action to 'Content' for the icon image files.
indyfromoz
So, the images are displayed, but they're always the same. I will post some XAML in my question so you can understand.
Bruno
I am unable to get any further clues, might need access to the full code. Your XAML looks alright to me. Are these pages user controls? Are you loading them within a Pivot/Panorama?
indyfromoz
I just inserted a new application page (I think thats the way its called).
Bruno