WPF MVVM

Effectively debugging WPF MVVM applications

Being able to effectively debug any application is key to the success of an application. Every developer, no matter how good they are or how long they have been writing code, introduces bugs. Debugging is the process of identifying bugs and removing them. WPF applications can be particularly hard to debug, if you are not using the correct tools. This post attempts to help you utilise various free tools to help simplify the debugging process. Binding Errors Binding errors are very common in all…

Continue reading

WPF Entity Framework Code First migrations

Recently I wrote a WPF application using Entity Framework Code First and released it into the wild. Shortly after, the business requirements changed and I had to make changes to the model. Thus, I was introduced to Code First migrations. I did a lot of research on Code First migrations and could only really find the most simple of examples, and almost robotic documentation on MSDN that provided minimal help. This post aims to provide a clearer view on migrations, and how to properly create…

Continue reading

Using StructureMap setter injection to inject repositories into your View Model

This short post is a follow on from an earlier series of posts that discussed how to achieve MVVM purity in WPF using Structure Map. You may want to check out those posts first before reading this post. However, if you just generally want to know how to do setter injection using Structure Map, you are in the right place! A Scenario It is very common in modern applications to have a repository that does the job of retrieving and saving data from/to your database. Your repository may look like…

Continue reading

WPF MVVM IoC containers - Part 2 of 2

The ultimate goal of MVVM is to achieve true separation of concerns, meaning that the various elements of your project know nothing about each other. It’s virtually impossible to achieve this in an elegant way in WPF without some outside help. You are reading the second part of this blog post where we will discuss how to use an IoC container properly in a WPF MVVM application. It is assumed you have either read the first post, or are familiar with the concept of IoC/dependency injection with…

Continue reading

WPF MVVM IoC containers - Part 1 of 2

The ultimate goal of MVVM is to achieve true separation of concerns, meaning that the various elements of your project know nothing about each other. It’s virtually impossible to achieve this in an elegant way in WPF without some outside help. For example, how to you tie the view model to a view? Here are some ideas that spring to mind; 1) You could set the data context directly in the view; You could set the data context in the views code behind file; Or you could set the data context when the…

Continue reading

WPF MVVM For WinForms Devs - Part 5/5

The purpose of this series of tutorials is to introduce the Model-View-ViewModel (MVVM) design pattern, and look at how to quickly and simply implement it in a Windows Presentation Foundation (WPF) application. This series is targeted at developers of all levels, but especially at developers who are looking to make the transition from Windows Forms to WPF. This final part of the series assumes you have at least read the previous parts, or have a good working knowledge of WPF and the MVVM design…

Continue reading

WPF MVVM For WinForms Devs - Part 4/5

The purpose of this series of tutorials is to introduce the Model-View-ViewModel (MVVM) design pattern, and look at how to correctly implement it in an Windows Presentation Foundation (WPF) application. This series is targeted at developers of all levels, but especially at developers who are looking to make the transition from Windows Forms to WPF. Events in Windows Forms applications Assuming you have come from a Windows Forms background, regardless of what design patterns (if any?) you used…

Continue reading

WPF MVVM For WinForms Devs - Part 3/5

The purpose of this series of tutorials is to introduce the Model-View-ViewModel (MVVM) design pattern, and look at how to correctly implement it in a Windows Presentation Foundation (WPF) application. This series is targeted at developers of all levels, but especially at developers who are looking to make the transition from Windows Forms to WPF. Capturing user input In the previous walkthrough we; set up our view model, bound it to the view, and added a property for our model class. We then…

Continue reading

WPF MVVM For WinForms Devs - Part 2/5

The purpose of this series of tutorials is to introduce the WPF MVVM (Model-View-ViewModel) design pattern, and look at how to correctly implement it in an Windows Presentation Foundation (WPF) application. This series is targeted at developers of all levels, but especially at developers who are looking to make the transition from Windows Forms to WPF. How to quickly implement MVVM in your C# WPF application Start by firing up an instance of your favourite version of Visual Studio (free or paid…

Continue reading

WPF MVVM For WinForms Devs - Part 1/5

The purpose of this series of tutorials is to introduce the WPF MVVM (Model-View-ViewModel) design pattern, and look at how to quickly and simply implement it in a Windows Presentation Foundation (WPF) application. This series is targeted at developers of all levels, but especially at developers who are looking to make the transition from Windows Forms to WPF. The first part of this series will focus on; What exactly is MVVM, and why should I care? What problem does the MVVM design pattern…

Continue reading