Archive For The “MVVM” Category

The Fat ViewModel

If someone asked you, what are the building blocks of MVVM, what would you say? Models, Views, and ViewModels, of course. It’s in the name. But really, there are two others: Models Views ViewModels Commands Events If Commands and Events aren’t strongly represented in your application, I’d say there is a strong chance it isn’t [...]

Read more »

Background event handling in Prism

Prism’s event aggregator is great for decoupling UI state changes when UI events occur, but sometimes you need to perform some larger, long-running task on a background thread — uploading a file, for example. Here’s a quick example of an encapsulated event handler listening off the Prism event bus, and using Windsor’s IStartable facility to [...]

Read more »

Reactive Extensions and Prism: LINQ to your Event Aggregator

A lot of people have been talking about the Reactive Extensions for .NET, a flash new library from Devlabs which lets you do LINQ to .NET events just like you can with collections. My team at work has started using it pretty heavily, and today I wrote an adapter that allows you to use Rx [...]

Read more »

Null Object pattern for a WPF ComboBox’s deselected value

Last week, I encountered a problem doing some fiddly UI behaviour in a Prism/MVVM app. I wanted something like this: FX curve: USD GBP EUR GBP I wanted a ComboBox where you can choose one of the available options, or none of them. Null, deselected, whatever. Unfortunately for me, WPF doesn’t support binding null values [...]

Read more »

TDD: Helper for checking PropertyChanged event gets raised

Today I am working on my first WPF app, using the WPF Model-View-ViewModel (MVVM) Toolkit. Naturally, we are using TDD — like ASP.NET MVC, WPF ViewModels and ICommands lend themselves very nicely to unit testing, even around difficult dependencies like OpenFileDialog. Anyway, one problem I am seeing repeated is writing tests for PropertyChanged events firing [...]

Read more »