有几种方法可以做到这一点,而不会破坏PRiSM的典型概念。 为[MSDN文档] [1](第9章:沟通松散耦合的组件之间)告诉我们:
当模块之间的通信,重要的是你知道的方法之间的差异,这样就可以最佳地确定哪种方法在您的特定场景中使用。棱镜库提供以下沟通方法:
Commanding. Use when there is an expectation of immediate action from the user interaction.
Event aggregation. For communication across view models, presenters, or controllers when there is not a direct action-reaction expectation.
Region context. Use this to provide contextual information between the host and views in the host's region. This approach is somewhat similar to the DataContext, but it does not rely on it.
Shared services. Callers can call a method on the service which raises an event to the receiver of the message. Use this if none of the preceding is applicable.
在你的情况下,你应该使用EventAggregator或RegionContext。共享ViewModel是可能的,但这是最后的手段。
视图是否共享视图模型? – 2010-11-26 16:43:46