有没有人知道使用Prism的WPF代码示例,其中每个模块在另一个模块的菜单中将自己注册为menuitem?
(我目前有一个应用程序尝试使用EventAggregator执行此操作,因此一个模块侦听来自其他模块的已发布事件,这些模块需要在菜单中将其标题作为菜单项,但我遇到了订单问题加载和线程等我想找到一个使用经典Prism结构来做这个的例子.)
我在考虑这个问题:
Shell.xaml:
<DockPanel>
<TextBlock Text="Menu:" DockPanel.Dock="Top"/>
<Menu
Name="MenuRegion"
cal:RegionManager.RegionName="MenuRegion"
DockPanel.Dock="Top"/>
</DockPanel>
Run Code Online (Sandbox Code Playgroud)
合同视图:
<UserControl x:Class="ContractModule.Views.AllContracts"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<MenuItem Header="Contracts">
</MenuItem>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
客户观点:
<UserControl x:Class="CustomerModule.Views.CustomerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<MenuItem Header="Customers">
</MenuItem>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
但是要知道我已经完成了非Prism MVVM应用程序结构,并且Menus总是很好地绑定到ViewModel中的ObservableCollections,上面似乎打破了这个漂亮的模式.以上是在Prism中做到这一点的习惯方式吗?