?
Solved

How to have multiple "Pages" to a windows phone app

Posted on 2012-09-17
5
Medium Priority
?
601 Views
Last Modified: 2014-11-12
I am building an app that will take the place of a character sheet in Dnd. The idea is that you press a button that says 'Personal' and it will clear the grid that the buttons are on from the screen, and pull up a grid that has the Personal info.

I can't find anything on google on how to do this. I am sure it is simple, but even so I don't know it or much C# actually... This is my second App, and I am still very much a beginner to windows phone developement.

Thanks in advance
0
Comment
Question by:dashifire
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:Kelvin McDaniel
ID: 38409508
dashifire,

The first thing to do is create a new page which will be the Personal info page. Let's assume you call this page/file "PersonalInfo".

Then, in the Personal button click event, enter the following code:

var dlg = new PersonalInfo();
dlg.Show();


That will launch the PersonalInfo page.

To clear the grid, unless you dynamically add its items in code (meaning you didn't drag and drop them on the page using the Designer), I suggest you put those in one of the collapsible controls... maybe a StackPanel? Let's call that "CharactersGrid". Then you can set that StackPanel's Visibility using...

CharactersGrid.Visibility = Visibility.Collapsed;

That way you won't run into issues with the controls not being there if you want to show them again later.

All together, this is what your Personal button's click event will look similar to:

void PersonalClick(object sender, RoutedEventArgs e)
{
    CharactersGrid.Visibility = Visibility.Collapsed;
    var dlg = new PersonalInfo();
    dlg.Show();
}

Open in new window

Or, if you truly do want to blow all the controls away for good (until you completely reload your CharactersPage) then you can do the following instead:

void PersonalClick(object sender, RoutedEventArgs e)
{
    CharactersGrid.Children.Clear();
    var dlg = new PersonalInfo();
    dlg.Show();
}

Open in new window

0
 

Author Comment

by:dashifire
ID: 38420395
Sorry it took so long to get back to this. Too many projects, too little time...

The Visibility worked like a charm, but the next part:

var dlg = new Page1();
dlg.Show;

Open in new window

resulted in a error line under the dlg.Show;

the error reads 'PhoneApp6.PersonalInfo' does not contain a definition for 'Show' and no extension method 'Show accepting a first argument of type 'PhoneApp.PersonalInfo' could be found(are you missing a using directive or an assembly reference?)

Any Ideas?
0
 
LVL 11

Accepted Solution

by:
Kelvin McDaniel earned 2000 total points
ID: 38421618
Oops, my bad. Forgot this was XAML. :)

Use this instead:
// Assuming PersonalInfo.xaml is in the root of the project...
var uri = new Uri("/PersonalInfo.xaml", UriKind.Relative));
NavigationService.Navigate(uri);

Open in new window

0
 

Author Closing Comment

by:dashifire
ID: 38423188
Perfect! That did it! I now have multiple pages! Thank you very much!<br /><br />btw, thanks IJZ for the links, I will put the resources to good use.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let me explain this picture a little bit.  First, in case you haven't already guessed, you are looking at my 2 phones, an Android Samsung Galaxy S5 on the left and an iPhone 5 on the right.  They are on their respective cradles on my desk.  But, you…
A short article about problems I had with the new location API and permissions in Marshmallow
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month15 days, 18 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question