This has little to do with the MVVM template per se, except for the fact that a view's dependency on its ViewModel is resolved through dependency injection.
How it works is pretty simple. There are 3 simple concepts for DI:
The first declares a dependency , where some object indicates that it depends on something, either through the constructor or property (as was the case in your example using DependencyAttribute ).
The second concept is registration, in which you register the implementation of the dependencies that your objects have (in your case, you registered the implementation of IQuoteSource ). Please note: you do not need to register ViewModel, because this is not an implementation of the interface you depend on.
The third one is that it glues things that allow dependencies , where you ask the container to allow some type for you, and it goes and looks at what dependencies the object declares (in your case, you allow MainWindow , which has a dependency on the ViewModel ) , finds the correct registered implementation and resolves it. This behavior is cascaded through the resolution of the object graph (which allows the ViewModel to IQuoteSource on IQuoteSource ).
Hope this helps :)
source share