General information
Category:
Windows Presentation Foundation (WPF)
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only