Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I am new to the windows phone app project.
But i encountered with some small problems like:

1.I cant find the reference "using system.windows.navigation"
2.How can I pass a value in a main page.xaml to page2.xaml
3.How can I pop up a message box?

I terribly fed up with searching these items and am failed to find out these things ...
Posted
Updated 18-Sep-15 1:25am
v2
Comments
Leo Chapiro 18-Sep-15 7:28am    
"I terribly fed up with searching these items "
I can't believe this, e.g. your third question - the simple Google search gets tons of examples:
https://www.google.de/#q=windows+phone+8.1+c%23+messagebox

1 solution

1) C# is a case-sensitive language, so if you would write

C#
using system.windows.navigation


It won't work, you have to use System.Windows.Navigation[^] namespace for your project. Just make sure you are referencing the DLL also, Double-click on References and see what DLLs are present.

2) I would like to have the data stored in the App context so that both of the pages can work around with the data that was passed.

C#
public static object Data { get; set; }


Which can then be altered as,

C#
// Before navigating
App.Data = "String data";
rootFrame.Navigate(typeof(Page2));

// After navigation
var data = (string)App.Data; // Get the data


This way you will be able to pass the data from one page to another, but also maintains the data in the Application context.

3) MessageBox doesn't exist in Metro applications. You get to preview the message as a dialog. A message dialog in Metro application is MessageDialog[^] object.

C#
new MessageDialog("Message to show").ShowAsync();


Note that these are asynchronous models, you would have to apply an await with them.
 
Share this answer
 
Comments
[no name] 18-Sep-15 7:57am    
i cant find any dll in reference.(windows app 8.1)
how can i store this in app.xaml?
Afzaal Ahmad Zeeshan 18-Sep-15 8:04am    
Because all of the references are already added. Please make sure that you are using "System.Windows.Navigation" (upper-case).

Not in App.xaml but in the code-behind. In the App.xaml.cs. Create a new member and keep it there.
[no name] 18-Sep-15 23:55pm    
i've a library named "using Windows.UI.Xaml.Navigation;"
but i cant pass a value to the next page.i want to welcome the user in second page
using System.Windows.Navigation showing error!!!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900