Auto ViewModelLocator In MVVM Pattern

I will present a little trick inside of the ViewModels instantiation in MVVM pattern.

Sometimes, we work in WPF small solutions, which does not usually need ViewModelLocator class as ViewModels class generator, because we don’t need to save ViewModels reference. We will not worry about feeding ViewModelLocatorclass and we will go to deploy our ViewModels classes immediately. This fits perfectly with the unit tests and binding engine.

We will get all this with a class with two WPF attached properties given below.