这是我的应用程序架构。请注意,我有指挥作为另一个指挥的孩子。我为每个导体设置了 IHandle 以接收来自它的孩子的消息。消息类型与我使用消息只是导航相同。我的问题是我将 ShellView 的 EventAggregator 传递给它的孩子。
NewConnectionView 的 EventAggregator 怎么样?因为我使用它的 EventAggregator 在 ShellView 上导航。并且它的孩子们可以在它的 ActiveItem 上导航。
如何在一个 ViewModel 中分离这 2 个 EventAggregator。
ShellView & NewConnectionView ==> Conductor.Collection.OneActive
+----------------------------------+
| ShellView |_|[]|x|
+----------------------------------+
| +------------------------------+ |
| | | |
| | | |
| | | |
| | ActiveItem | |
| | | |
| | | |
| | | |
| +------------------------------+ |
+----------------------------------+
/ \
/ \
/ \
/ \
/ \
/ \
/ \
+----------------------------------+ +----------------------------------+
| NewConnectionView |_|[]|x| | ConnectionListView |_|[]|x|
+----------------------------------+ +----------------------------------+
| +------------------------------+ | | TextBlock |
| | ComboBox | V | | | +----------------------+ +-----+ |
| +------------------------------+ | | | | | Btn | |
| +------------------------------+ | | | | +-----+ |
| | | | | | | +-----+ |
| | | | | | | | Btn | |
| | | | | | DataGrid | +-----+ |
| | ActiveItem | | | | | +-----+ |
| | | | | | | | Btn | |
| | | | | | | +-----+ |
| | | | | | | |
| +------------------------------+ | | +----------------------+ |
+----------------------------------+ +----------------------------------+
/ \
/ \
/ \
/ \
/ \
/ \
/ \
+----------------------------------+ +----------------------------------+
| FileConnectionView |_|[]|x| | DatabaseConnectionView |_|[]|x|
+----------------------------------+ +----------------------------------+
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
+----------------------------------+ +----------------------------------+
目前,我的方法是使用 NewConnectionShellView (Screen) 作为 NewConnectionView 的 (Conductor) 父级来分离 EventAggregator。但问题是,我无法将 NewConnectionView 的子项的 DisplayName 显示到我的主窗口(ShellView)中。
请注意,我没有使用 MEF。我的问题有什么解决方法吗?
+----------------------------------+
| ShellView |_|[]|x|
+----------------------------------+
| +------------------------------+ |
| | | |
| | | |
| | | |
| | ActiveItem | |
| | | |
| | | |
| | | |
| +------------------------------+ |
+----------------------------------+
/ \
/ \
/ \
/ \
/ \
/ \
/ \
+----------------------------------+ +----------------------------------+
| NewConnectionShellView |_|[]|x| | ConnectionListView |_|[]|x|
+----------------------------------+ +----------------------------------+
| +------------------------------+ | | TextBlock |
| | | | | +----------------------+ +-----+ |
| | | | | | | | Btn | |
| | | | | | | +-----+ |
| | | | | | | +-----+ |
| | | | | | | | Btn | |
| | | | | | DataGrid | +-----+ |
| | ActiveItem | | | | | +-----+ |
| | | | | | | | Btn | |
| | | | | | | +-----+ |
| | | | | | | |
| +------------------------------+ | | +----------------------+ |
+----------------------------------+ +----------------------------------+
|
|
|
|
|
|
|
|
V
+----------------------------------+
| NewConnectionView |_|[]|x|
+----------------------------------+
| +------------------------------+ |
| | ComboBox | V | |
| +------------------------------+ |
| +------------------------------+ |
| | | |
| | | |
| | | |
| | ActiveItem | |
| | | |
| | | |
| | | |
| +------------------------------+ |
+----------------------------------+
/ \
/ \
/ \
/ \
/ \
/ \
/ \
+----------------------------------+ +----------------------------------+
| FileConnectionView |_|[]|x| | DatabaseConnectionView |_|[]|x|
+----------------------------------+ +----------------------------------+
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
+----------------------------------+ +----------------------------------+