Link to home
Start Free TrialLog in
Avatar of dashifire
dashifireFlag for United States of America

asked on

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

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
Avatar of Imran Javed Zia
Imran Javed Zia
Flag of Pakistan image

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

Avatar of dashifire

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Kelvin McDaniel
Kelvin McDaniel
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.