NavigationService.GoBack()
; 我在 viewmodel 中设置了一个变量,然后我想返回,当我返回时我想使用该变量,但似乎没有运行,我不想刷新该页面。
有任何想法吗?
在这里我正在设置变量,我想回到我的 MainPage。
void item_click(object sender, RoutedEventArgs e)
{
Button b = e.OriginalSource as Button;
App.ViewModel.bName = b.Content.ToString();
App.ViewModel.bID = b.Name;
this.NavigationService.GoBack();
}
在我的 MainPage 中,我想运行检查以查看变量是否已更改。
public MainPage()
{
/*
i don't want to run this actually, when i'm coming back from my secondarypage.
InitializeComponent();
InitializeSettings();
*/
if (App.ViewModel.bName != null)
{
myButton.Content = App.ViewModel.bName;
myButton.Name = App.ViewModel.bID;
}
}