C# 使用WPF 在Page中点击 ListBox的一条ListBoxItem,触发SelectionChanged()方法到另外一个Page,再次返回,点击该条ListBoxItem无反应。

Page1点击跳转Page2:

private void myListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
  object o = listBox.SelectedItem;
  if (o == null)
  return;//这两句必须有
  string aaa = o.ToString();
  Page2 page2 = new Page2(aaa, whichOne);
  this.NavigationService.Navigate(page2, UriKind.Relative);
}

Page2 点击跳转返回Page1:

if (NavigationService.CanGoBack)

            {

                NavigationService.GoBack();

            }

这样,返回后再次点击该条,即可再次触发SelectionChanged()

posted @ 2020-11-17 13:57  Python5421  阅读(454)  评论(0编辑  收藏  举报