Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MVVM conundrum
Message
From
06/07/2011 08:21:33
 
 
To
All
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Title:
MVVM conundrum
Environment versions
Environment:
C# 4.0
Miscellaneous
Thread ID:
01517403
Message ID:
01517403
Views:
115
Hi,

Stuck as to the best way to handle this (actually at the moment I'm stuck for *any* way but....)

Example of problem:

A WPF Window wired up to ViewModelA.
Within the Window is a Grid wired up to ViewModelB.
The Grid contains a button which, when clicked needs to send some info from ViewModelB to ViewModelA.
The command handler in ViewModelB uses the Prism EventAggregator to publish and ViewModelA subscribes.
So far, so good BUT:
The button should only be enabled only when certain conditions are met in both ViewModelB *and* ViewModelA.
ViewModelB is easy since I can use the CanExecute().
But how to have the button state also dependent on ViewModelA's conditions?

Criteria for solution :
ViewModelA and ViewModelB can only communicate via publish/subscribe
No code-behind in the Views....

I guess I could change things so that ViewModelB is nested within ViewModelA and the button is wired to ViewModelA - but I'd rather avoid that since ViewModelB will not always be relevant to ViewModelA.

TIA for any suggestions,
Viv

UPDATE: Never mind (unless you can think of something more generic) . I just raised an event in ViewModelA when the relevant status changes and subscribe to and track it in ViewModelB.
Next
Reply
Map
View

Click here to load this message in the networking platform