Reputation: 3788
I'm working on a wp7 application which consists of two xaml pages. Pages are Page1 and Page2. Page1 consists of a slider which has a range of values between 0 to 10. My program is,if I slide the slider to reach value = 10,it should navigate to Page2. So far so good. But when Page2 is loaded,I want my slider to set its value to 0. But when I press the "back" key on my windows phone,the Page2 navigates to Page1 & the slider has the value = 10 (which should be 0). I cannot do the coding of slider from Page2 because it cannot access it! How should I do it?
The program for Page1(MainPage) is
namespace ProgressBar
{
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
}
private void slider1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (slider1.Value == 10)
{
NavigationService.Navigate(new Uri("/Page2.xaml", UriKind.Relative));
}
}
}
}
Upvotes: 1
Views: 540
Reputation: 26344
Reset the Slider value to 0 in the Page.OnNavigatedTo event.
Upvotes: 1
Reputation: 52280
in this case just reset the slider to 0 before navigating to your Page2 or when you navigateback (there is a event for this in the NavigationService).
To share information accross your application in the general case you can just use static-classes/fields or objects your parse around or just persit the settings/info on file. It's the same as with any other environment.
Upvotes: 1