有幾種方法可以做到這一點,而不會破壞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