Answer the question
In order to leave comments, you need to log in
WPF Accessing objects of another page
There are two pages - Page1.xaml and Page2.xaml. Some variable is defined in Page2 public string variable{ get; set; }
How can I set this variable from Page1?
Answer the question
In order to leave comments, you need to log in
It is not obvious from the question how Page1 and Page2 are connected.
If Page1 is called from Page2, then the easiest way to call is to create an instance of Page2 and assign a value to a variable.
Can be used to pass a transition state object, an optional parameter to the Navigate method. Example from MSDN:
void goButton_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new ContentPage(), DateTime.Now);
}
void NavigationService_LoadCompleted(object sender, NavigationEventArgs e)
{
DateTime requestDateTime = (DateTime)e.ExtraData;
string msg = string.Format("Request started {0}\nRequest completed {1}", requestDateTime, DateTime.Now);
MessageBox.Show(msg);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question