Q:

best way to switch between using implementations of interface in ViewModel

I have a WPF project using the MVVM pattern.  I have an interface that for this purpose I'll call IMyData which I currently have 2 implementations of myDataImplA & myDatImplB.  I want my ViewModel to be able to switch between using these 2 implementations on the fly.  Currently I am passing in both implementations of the interface into the ViewModel's constructor and have Boolean property in which a ToogleButton in the View is bound to determine which one to use.  I feel like there is probably a better way to do this and passing in both implementations of IMyData just feel wrong.  Also if I end up having a 3rd implementation of IMyData my current method of using a Boolean to determine the implementation of IMyData to use won't work.
The interface could be updated on the fly from the view, but that would break MVVM as I think that would require extra code-behind in my View.I am looking for a more scalable solution which fits within MVVM.

A:

You're assumption this is wrong is, IMO, accurate.  The whole reason to implement the IMyData should be to avoid this behavior altogether.  
I'm not sure how you have the project setup but just to help you along solving this logic consider the ViewModel just an endpoint where business logic does not live.  Your ViewModel should communicate to a DAL (Data Access Layer), in which case, will pump out Model information that it updates against.  
Since you're using an interface the DAL should provide that interface instantiated to the ViewModel.  Implement a command (ICommand) in the ViewModel that dictates state only, such as an enum.  Tell the DAL which state you want.  When the DAL updates your ViewModel should be listening and react to it.  At this point the ViewModel then updates the IMyData property, which should be notifying listeners, and the View will automatically change (If everything is wired up correctly.). 
This probably sounds confusing so I'll try to simplify a different way.
Keep the references in a one way direction at all costs.
View -> ViewModel -> DAL  (DAL is considered Model in MVVM, which in your case pumps out IMyData).
Let the View bind to a command in ViewModel stating if it wants StateN for example.
ViewModel then tells DAL to switch to StateN or automatically looks for StateN models.
DAL then changes the IMyData type to the type that works in StateN.
The ViewModel is listening to DAL for changes and when the DAL says StateNChanged the ViewModel updates the IMyData property from the DAL, which fires off a notification.  
The View, bound to the ViewModel, then updates based on the new data.  
If this doesn't make sense, post most of the code and I'll make the modifications and show it.

