显示一个对话框窗口,我有两个棱镜模块。 我想其中的一个注册窗口,使用“显示对话框”模式的另一个显示该窗口。 如何做(如果可以做到)?棱镜:通过两个模块
3
A
回答
1
嘛。我想我通过遵循this tip来解决它。但我不知道这是否是最好的解决方案。
我刚刚创建我的壳牌项目的窗口。这个窗口将会弹出一个对话窗口。
下面是它的代码:
Popup.xaml:
<Window x:Class="TryERP2.Shell.Views.Popup"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Popup" Height="315" Width="411"
xmlns:prism="http://www.codeplex.com/prism">
<Grid>
<ContentControl x:Name="DialogRegion" Grid.Row="1" prism:RegionManager.RegionName="DialogRegion" />
</Grid>
</Window>
Popup.xaml.cs:
public partial class Popup : Window
{
private static Popup popup;
private Popup(IRegionManager regionManager)
{
InitializeComponent();
RegionManager.SetRegionManager(this, regionManager);
}
//Using the singleton pattern
public static Popup getPopup(IRegionManager regionManager)
{
if (popup == null)
popup = new Popup(regionManager);
return popup;
}
}
最后,当我想显示对话框(在一个命令,它是在一个模块中),我只是实例并告知什么是RegionManager:
private void showDialog()
{
// Acquiring the RegionManager
var regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
// Getting the Popup object
Popup p = Popup.getPopup(regionManager);
// Looking for the view I want to show in the dialog
var x = new Uri("MyView", UriKind.Relative);
// Changing the view of the DialogRegion (which is within the Popup)
regionManager.RequestNavigate("DialogRegion", x);
// Showing the dialog
p.ShowDialog();
}
1
是的,是可以做到的。这是大概步骤:
申报界面这一观点在“基础设施”项目
public interface IMyDialogWindow
{
}
[出口]类,你的模块
[Export(typeof(IMyDialogWindow))]
public class MyClassInModuleA : IMyDialogWindow
{
}
[导入]这个类实现此接口在其他模块,并使用它的对话框
[Import]
public IMyDialogWindow PropertyInModuleB
相关问题
- 1. 与棱镜之间的模块通信?
- 2. 棱镜依赖模块
- 3. 棱镜模块化实践
- 4. 棱镜模块依赖
- 5. 棱镜,MVVM和模块化
- 6. 棱镜统一容器每个模块
- 7. 棱镜+ MEF:延迟棱镜模块的服务出口
- 8. 具有多个模块和模块的棱镜取决于
- 9. 在棱镜模块中更改视图?
- 10. 参数传递到棱镜模块
- 11. 负载棱镜模块(在启动时)
- 12. 棱镜模块化/类型交换
- 13. 棱镜模块化重载机制
- 14. WPF,MVVM和棱镜模块化
- 15. 在棱镜区域显示模块
- 16. 棱镜模块和数据库
- 17. 棱镜模块依赖关系wpf
- 18. 棱镜模块生命周期
- 19. 棱镜wfh通过实体模态为模态查看
- 20. 带独立模块管理器的加载棱镜模块
- 21. 棱镜CompositePresentationEvent闪光两次
- 22. 棱镜加载第三个DLL时,模块启动
- 23. 无法使用“棱镜模板包”创建棱镜页面
- 24. 棱镜外壳模板,创建两个ShellView实例
- 25. 升级CAB和棱镜2棱镜4
- 26. 复合WPF(棱镜)模块资源数据模板
- 27. GWT - 通过EventBus连接两个模块
- 28. 棱镜导航
- 29. ViewModelLocator棱镜mvvm
- 30. 棱镜scultpure Silverlight
你可以发布一些示例代码?我完全无法理解你的答案。我必须复制另一个项目中的文件?我正在考虑以何种方式将视图注册到第一个模块的IoC容器中,然后“读取”并在第二个模块上显示。 – 2012-01-18 01:01:40
您必须通过可以放置在“基础设施”模块中的接口“粘合”ModuleA和ModuleB。通过这种方式,ModuleB将能够在不知道它的情况下从ModuleA导入窗口。 – katit 2012-01-18 01:31:22
谢谢。它是否可以与Unity一起使用? – 2012-01-18 12:14:29