Posted by : Sudhir Chekuri Friday, 25 October 2013


Windows phone 8 apps C# navigation code with sending values from one page to other

Here is the code to under a button click to navigate from mainpage.xaml to Plans.xaml
In the below code hello is the text present inside a string planCategory.
the value inside planCategory is sent to the plans.xaml page using the below code.


string planCategory="Airtel,SMSPlan";
 NavigationService.Navigate(new Uri("/Plans.xaml?msg=planCategory , UriKind.Relative));


Code in second page ie., Plans.xaml to display text which is sent in the before page


 int i=0;
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            string msg = "";

            if (NavigationContext.QueryString.TryGetValue("msg", out msg))
           
                i=msg.IndexOf(',');
                
                PageTitle.Text = msg.Substring (0,i);
                PlanCategory.Text = msg.Substring(i+1, msg.Length - i);


        }


Leave a Reply

Subscribe to Posts | Subscribe to Comments

Followers

Total Pageviews

Powered by Blogger.

Blog Archive

- Copyright © 2013 DevStudent - Metrominimalist - Powered by Blogger - Designed by Johanes Djogan -