Search code examples
c#silverlightwindows-phone-7windows-phone-7.1application-bar

How do I link/navigate a application bar icon to a new WP page?


Hello Stack Overflow community,

I'm in the process of learning WP7 development, I'm struggling with one thing.

How can I link an application bar icon to a new WP7 page in the same solution.

I know where to find the icons (prog files>x86>SDK>7.1>Icons) and how to move them to the icon directory in the solution explorer, just want to know how I can actually link it to a page.

Hope you can help, I understand this may be a silly question :)


Solution

  • The Icon-format in XAML:

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar Mode="Default" Opacity="1.0" IsMenuEnabled="True" IsVisible="True">
            <shell:ApplicationBarIconButton Click="NavigateButtonClick" IconUri="/Images/image.png" Text="go" />
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    

    And the code:

    private void NavigateButtonClick(object sender, EventArgs e)
    {
        NavigationService.Navigate(new Uri("/YourPage.xaml", UriKind.Relative));
    }