I would like to click on a button to take me to a page , then click on a listbox item, click on a button on the new page and pass it back to the page before without creating a new URI of the first page.
**First Page**
private void btnAddExistingMember_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/ChooseMember.xaml", UriKind.Relative));
}
**Second page after choosing listbox value**
private void btnAddSelected_Click(object sender, RoutedEventArgs e)
{
Member currMember = (Member)lstMembers.SelectedItem;
string memberID = currMember.ID.ToString();
//navigate back to first page here passing memberID
}
can it be done?
Thank you
You can store the member in the App.xaml.cs file. This is common file accesssible for all files in the application. This works like a global variable.
//App.xaml.cs
int datafield ;
//Page1xaml.cs
(App.Current as App).dataField =10;
//Page2.xaml.cs
int x = (App.Current as App).dataField
You could create a manager class that would hold the member id. This manager class could then be accessed from both your first page and ChooseMember page.
An example of a Singleton Manager class :-
public class MyManager
{
private static MyManager _instance;
public static MyManager Instance
{
get
{
if (_instance == null)
{
_instance = new MyManager();
}
return _instance;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With