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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top