gpt4 book ai didi

wpf - Prism RequestNavigate 不起作用

转载 作者:行者123 更新时间:2023-12-04 09:56:03 25 4
gpt4 key购买 nike

在每个 View 中

public partial class View2 : UserControl, IRegionMemberLifetime, INavigationAware
{

public bool KeepAlive
{
get { return false; }
}

bool INavigationAware.IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
void INavigationAware.OnNavigatedFrom(NavigationContext navigationContext)
{
// Intentionally not implemented.
}
void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
{
this.navigationJournal = navigationContext.NavigationService.Journal;
}

}

初始化:
container.RegisterType<object, View1>("View1");
container.RegisterType<object, View2>("View2");

regionManager.RequestNavigate("Window1", new Uri("View1", UriKind.Relative));
regionManager.RequestNavigate("Window2", new Uri("View2", UriKind.Relative));

我正在遵循开发人员指南,如果 View 存在,它不会更改 View 。

最佳答案

你确定 View 被容器填充了吗?

我建议您为 RequestNavigate 方法提供回调,这样您就可以通过 NavigationResult 跟踪 View 中发生的情况。 :

regionManager.RequestNavigate
(
"Window1",
new Uri("View2", UriKind.Relative),
(NavigationResult nr) =>
{
var error = nr.Error;
var result = nr.Result;
// put a breakpoint here and checkout what NavigationResult contains
}
);

关于wpf - Prism RequestNavigate 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5925327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com