wpf - Navigate to new window in Prism WPF
问题描述
QUESTION 1
I know there is a way to open popup dialog with custom view using InteractionRequestTrigger, PopupWindowAction and InteractionRequest. But I am looking for solution like registering Window and WindowViewModel for navigation and call INavigationAsync.Navigate("SomeWindowUri", someParameters). It seems much simpler and cleaner solution. Does Prism support such approach?
QUESTION 2
I have main window (MainWindow) and new window (NewWindow) to be displayed from MainWindow. I am trying to display some view in region which is defined in NewWindow. When I use IRegionManager.RegisterViewWithRegion it works as expected. But when I display NewWndow and then call IRegionManager.RequestNavigate nothing happens. The method IRegionManager.RequestNavigate works as expected when region is in MainWindow. Is it my mistake or Prism cannot do navigation in separate window?
Here is an example: https://bitbucket.org/equo/prismregionnavigationtest.git It is modified example of Prism example for WPF: 17-BasicRegionNavigation. After opening new window there nothing happens when clicking on any button, but ViewA or ViewB should be displayed below. After uncommenting MainWindow1 in App.CreateShell method the window works as expected.
解决方案
根据问题 1: Prism 团队正在开发新的对话服务,这正是我想要做的。https://github.com/PrismLibrary/Prism/pull/1682 它已经通过 prism 的预览版提供。
根据问题 2:要使其正常工作,需要创建作用域区域并将其附加到新创建的窗口。
_ScopedRegion = _RegionManager.CreateRegionManager();
RegionManager.SetRegionManager(newWindow, _ScopedRegion);
然后用它在新窗口中导航。
_ScopedRegion.RequestNavigate("NewRegion", "ViewA");
演示在这里: https ://bitbucket.org/equo/prismregionnavigationtest.git
推荐阅读
- vue.js - 如何使用赛普拉斯选择 (Vue) v-select 选项?
- javascript - 尝试编写 discord bot 以要求特定命令的特定角色
- postgresql - Docker 错误 - 5432:绑定:地址已在使用中
- swift - SwiftUI 的问题:带有按钮的垂直滚动视图
- flutter - VSCODE 和 Visual Studio Android 模拟器
- swift - 如何使用 SPM 构建 iOS 特定包?
- java - Kafka Spring 消费者偏移量未使用 ConsumerRecordRecoverer 提交
- delphi - 在 Delphi 中,如何在 64 位发布版本中修复 FreeAndNil 上的访问冲突(当 64 位调试版本工作时)?
- python - 如何在不同长度的列表之间进行迭代?
- android - Firebase DatabaseReference 空指针异常