Reputation: 2682
I know that I can pass values between pages with uri, for example:
NavigationService.Navigate(
new Uri("/DestinationPage.xaml?parameter1=v1", UriKind.Relative)
);
Is there any other ways how I can pass values between pages?
Upvotes: 2
Views: 1604
Reputation: 117
<Button Content="Next page" Grid.Column="1" Height="23" Tag="/NextPage.xaml" HorizontalAlignment="Right" Margin="0,6,12,0" Name="btnViewQuestion" VerticalAlignment="Top" Width="100" />
Upvotes: 2
Reputation: 1202
You Can pass values Using IsolatedStorageSetting, You have to be careful when using isolatedStorage, you have to Clear it manually,it won't be cleared unless you do so or uninstall The Application/Shut down the emulator , IsolatedStorage Documentation
Upvotes: 2
Reputation: 4088
You could make a Singleton ;). Here is an example:
public class MySingleton
{
private static MySingleton _mInstance;
public static MySingleton Instance
{
get { return _mInstance ?? (_mInstance = new MySingleton()); }
}
/// <summary>
/// You can send values through this string.
/// </summary>
public string SomeString { get; set; }
}
EDIT: To assign a value to it you can do something like this:
MySingleton.Instance.SomeString = "Text";
Upvotes: 4
Reputation: 7233
Besides passing strings in the page uri and retrieving them with the NavigationContext, there isn't any out-of-the-box option!
But you can always declare public properties in the App class that will be available for all pages!
Upvotes: 2
Reputation: 11844
You can use a query string value like
NavigationService.Navigate(new Uri("/MainPage.xaml?value=Hello%20World", UriKind.Relative);
and the value can be passed to as
string value = this.NavigationContext.QueryString["value"];
Upvotes: 2