fbpx

View model (MVVM) usage explanation

Problem statement

While working with add-ins, 80% of the time we are recycling old WPF UI’s into new projects. This pushes us to be as productive as possible when creating the components.

One of the best practices we found during this process, is to use MVVM to feed context to the different components.

How to implement it on add-ins?

MODEL: Build the model for the view and implement INotifyPropertyChanged. INotifyPropertyChanged interface is used to notify the view or ViewModel that property was updated.

VIEW MODEL: To expose relevant data and behaviors to the view. Behaviors are usually exposed with Commands

VIEWS: There are many ways to bind DataContext to a view, in this case it will be added in the OnStartup method.

And just use the property names on the ViewModel to bind data into the view:

440 Views
Author
Ssr Backend Developer at e-verse

I’m a proactive person who likes to face new challenges, always looking to learn and improve my skills. In my free time I’m always looking for new technologies that could be applied both in my job or in my personal projects. I think that’s one of my hobbies, so there’s no better way to say that I really enjoy programming. I strongly believe that teamwork and collaboration makes us better professionals


We build better solutions together.

Helpful Links: