wpf 快速开发框架_wpf实现框架frame中旧页面跳转新页面

更新时间:2019-06-10    来源:WPF    手机版     字体:

【www.bbyears.com--WPF】

这里有个方法非常简单:思路很简单,就是循环找到当前page的parent window,找到最顶级的然后跳转即可。

 代码如下

Frame pageFrame = null;
  DependencyObject currParent = VisualTreeHelper.GetParent(this);
  while (currParent != null && pageFrame == null)
  {
 pageFrame = currParent as Frame;
 currParent = VisualTreeHelper.GetParent(currParent);
  }
  // Change the page of the frame.
  if (pageFrame != null)
  {
 pageFrame.Source = new Uri("WindowPages/LawCase/LawCasePanel.xaml", UriKind.Relative);
}

本文来源:http://www.bbyears.com/asp/54079.html