New: XDA launches forum for app developers. Discuss coding, tools, marketing, and more.
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
the92playboy
Old
#1  
Member - OP
Thanks Meter 5
Posts: 97
Join Date: Jan 2008
Default Newb Programming Question

Firstly, I apologize for so a terribly novice question; I have looked and googled but part of my problem is I believe I am asking the question wrong.

So, I am just trying to build a VERY simple wp7 program. Main page would have several buttons, which pressing would take you to a page with information on the topic of the button you just pushed, and with another button back to the home screen. Again, very simple. For example, it could be an app of The Rolling Stones, and each button would be a link to a band member's small bio. Nothing too fancy, just dipping my toes.

My problem is I cannot find the action I need to attribute to a button. I can build the home screen and add buttons and text easy enough, and make the other "pages" or screens, but I do not know how to make the button navigate to those pages. And every search I do results in explanations of how to add web links, which is not what I want to do.

Sorry for the newb question, but I appreciate all responses and advice.
 
sensboston
Old
#2  
Recognized Developer
Thanks Meter 323
Posts: 1,252
Join Date: Nov 2009
Location: Boston, MA

 
DONATE TO ME
There are several ways to do the job:

1. - Define "Click" event for Button (double click on button in designer or on events properties);
- Add "using System.Windows.Navigation;" at the top of your main page .cs file;
- Add "NavigationService.Navigate(new Uri("/NewPage.xaml", UriKind.Relative));" to the "Click" event handler

2. - Open you page in Expression Blend;
- In the "Assets" (left top corner) window select "Behaviors";
- drag "NavigateToPageAction" to your button;
- fill "TargetPage" property (at the right top corner)

3. You may also manually edit your page.xaml source (see the source changes after using method 2)
 
john1506
Old
#3  
Junior Member
Thanks Meter 0
Posts: 9
Join Date: Oct 2009
Location: Wigan
Put any Button on the Page, simply Double Click that button, this will generate by Default a Click Action Event Handler, in this write the following

NavigationService.Navigate(new Uri("PageName.xaml", UriKind.Relative));

also, you should NOT add buttons to go back, developers are encouraged to have users using the hardware key for going back as you are simply adding more and more to the Navigation Stack which is responsible for keeping track of the users Navigation through Apps, kind of like your Web Browser, you navigate to google,. then 10 pages later, and if you navigate back by URL rather than the built in "GoBack" function for the browser, you end up clicking the back button a hundred times going forward to the page you stopped looking for information then to every page in between which you navigated through to get to that information, it just uses more Memory and for a users experience you should not use buttons that go back let the user control the flow

Good luck on your app mate