0
我有一个主窗口只包含的区域显示其他浏览:PRISM导航到另一个View
<ContentControl Grid.Row="1" prism:RegionManager.RegionName="ContentRegion"/>
我所要做的,就是马上当我MainWindowViewModel
负荷,导航到MainPageViewModel
。
我试图实现接口INavigationAware
如下列:
public void OnNavigatedTo(NavigationContext navigationContext)
{
_regionManager.RequestNavigate("ContentRegion", App.Experiences.DetailPage.ToString());
}
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
public void OnNavigatedFrom(NavigationContext navigationContext)
{
_regionManager.RequestNavigate("ContentRegion", App.Experiences.DetailPage.ToString());
}
但是,即使当我把我的断点过这些,他们是永远不会被执行。
我在做什么错?
编辑
也许我需要改变我的引导程序逻辑是什么?下面是它的样子:
public class Bootstrapper: UnityBootstrapper
{
protected override System.Windows.DependencyObject CreateShell()
{
return Container.TryResolve<MainWindow>();
}
protected override void InitializeShell()
{
Application.Current.MainWindow.Show();
}
protected override void ConfigureContainer()
{
base.ConfigureContainer();
Container.RegisterType(typeof(IDataRepository), typeof(DataRepository), null,new Microsoft.Practices.Unity.ContainerControlledLifetimeManager());
Container.RegisterTypeForNavigation<MainPage>(App.Experiences.MainPage.ToString());
Container.RegisterTypeForNavigation<DetailPage>(App.Experiences.DetailPage.ToString());
}
}
你想要的是,当应用程序加载导航到App.Experiences.DetailPage吧?另外,当您导航到页面时,会调用OnNavigatedTo/From。你必须调用region.RequestNavigate在某种形式的事件(按钮点击等) – Zippy
我可以肯定地通过按钮单击,但我试图在我的应用程序初始化时自动加载适当的(默认)视图 –