views:

35

answers:

1

How do I show a new form in a Windows Phone 7 App? I've initialized my class like this:

Jeans jeansform = new Jeans("Elwood Curtis");

However, there's no jeansform.Show() method.

+5  A: 

Generally windows phone 7 application use a form navigation similar to a silverlight navigation application hosted by a browser. This allows the phone back button to navigate back from "pages" which have been navigated to.

Your Jeans "form" should actually derive from PhoneApplicationPage and should have a simple default constructor (not one that accepts a parameter as you have at present).

You would then navigate to your page with code like this:-

NavigationService.Navigate(new Uri("/Views/Jeans.xml?name=Elwood%20Curtis"));

Your "Jeans" page then does most of its initial configuration in OnNavigatedTo:-

    protected override void OnNavigatedTo(Microsoft.Phone.Navigation.PhoneNavigationEventArgs e)
    {
        base.OnNavigatedTo(e);
        Name = NavigationContext.QueryString["name"];
        // Other code you would have otherwise run in a parameterised constructor
    }
AnthonyWJones