Question

In my project I have many Views and Viewmodels each view is selected using the current active viewmodel. Everything works fine, I have a toolbox in my project with few buttons basically options to "Save", "Delete" etc. This toolbox is Common for all views.
Here is my real problem starts i want to trigger the Command based on the Current View model like how I am loading all the views. For example there is a SaveCommand in all Viewmodel how will i trigger the Command associated with the "Current Viewmodel".
Is this even possible? or Am I completely wrong?

Was it helpful?

Solution

You should simply use the following binding:

Command={Binding CurrentViewModel.SaveCommand}

This will always bind to the SaveCommand found on the CurrentViewModel and when/if you change the current VM, this will automatically rebind itself.

I assume that the master view model contains such "current" or active view model as its own property.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top