Wpf-NavigationService.GoBack()和Listbox SelectionChanged事件
在ADDPage.xaml页面中,有一个返回按钮,其代码为NavigationService.GoBack(),用于返回上一页 问题: 在另一个页面(SubPage.xaml)的列表框SelectionChanged事件中,我正在使用NavigationService.Navigate(new ADDPage(search))Wpf-NavigationService.GoBack()和Listbox SelectionChanged事件,wpf,navigation,selectionchanged,Wpf,Navigation,Selectionchanged,在ADDPage.xaml页面中,有一个返回按钮,其代码为NavigationService.GoBack(),用于返回上一页 问题: 在另一个页面(SubPage.xaml)的列表框SelectionChanged事件中,我正在使用NavigationService.Navigate(new ADDPage(search)) 当页面执行ADDPage.xaml页面的NavigationService.GoBack()时,控件将移动到SubPage.xaml的Listbox SelectionC
当页面执行ADDPage.xaml页面的NavigationService.GoBack()时,控件将移动到SubPage.xaml的Listbox SelectionChanged事件,并再次加载同一页面。有没有更好的解决办法 我使用委托解决了我的问题 子页面.xaml.cs
public delegate void RefreshHandle(string message);
public partial class SubPage : PhoneApplicationPage
{
public static RefreshHandle RefreshCallback;
void Button_Click(object sender, EventArgs e)
{
string msg = "Test";
RefreshCallback(msg);
NavigationService.GoBack();
}
}
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
SubPage.RefreshCallback += new RefreshHandle(RefreshFn);
}
void RefreshFn(string message)
{
MessageBox.Show(message);
}
}
MainPage.xaml.cs
public delegate void RefreshHandle(string message);
public partial class SubPage : PhoneApplicationPage
{
public static RefreshHandle RefreshCallback;
void Button_Click(object sender, EventArgs e)
{
string msg = "Test";
RefreshCallback(msg);
NavigationService.GoBack();
}
}
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
SubPage.RefreshCallback += new RefreshHandle(RefreshFn);
}
void RefreshFn(string message)
{
MessageBox.Show(message);
}
}