Saturday, September 15, 2012

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

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 :)

Answers & Comments...

Answer: 1

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)); } 
by : Abbashttp://stackoverflow.com/users/880511

Answer: 2

When you define the handler for the Click event on the icon (in XAML this will be something like Click="ApplicationBarIconButton_Click") You need to fire a Navigation command, similar to the following...

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

where /MyNewPage.xaml is the relative path to the page you want to visit.

by : ZombieSheephttp://stackoverflow.com/users/377




2 comments:

Anonymous said...

I really like your blog.. very nice colors & theme. Did you design
this website yourself or did you hire someone to do
it for you? Plz respond as I'm looking to create my own blog and would like to know where u got this from. kudos
Feel free to surf my page ; Nubby Sweater Color Knit Dress

Vinod said...

What do you want to know from me..

Post a Comment

Send us your comment related to the topic mentioned on the blog