WPF and MVVM discovery

In our setup, we have operations that cannot realistically be run by the installer itself, so we have a separate application that updates various components at the end of the setup. I am rewriting this app so it’s cleaner (which isn’t very difficult considering the current state), and taking this opportunity to familiarize myself with WPF and the MVVM pattern.

I am using MVVM Light, and it’s a bit of a pain. There is exactly zero official documentation. It’s a real shame, considering that it’s one of the most used MVVM frameworks. I would love to use Caliburn.Micro because it’s well documented and supported, but using it in conjunction with MahApps.Metro adds yet another layer of complexity, and I am already learning about many things at once.

Creating a responsive UI in WPF using MVVM involves many steps and components. I will need to do my work in a BackgroundWorkerautoscroll a text box, etc, and bind it in my MVVM view. What I can find here and there often lacks a few important points, but it’s generally easy to find help.

Your ViewModel needs to declare public properties for each of the things displayed in the view, that you might want to change in the ViewModel. For instance, with a progress bar, if you don’t know how many steps you will have in advance, but you don’t want to use percentages, you will need to bind the Maximum property in the VM. Opening message and confirmation boxes should be done in the view, otherwise your VM unit tests will open dialog boxes that you can’t close. To do that, you need to create a messaging system.

All in all, I still don’t like WPF/MVVM very much. It’s very verbose, and doing anything takes a huge number of steps, namespaces importing, classes, workers, commands, and messaging back and forth. I have yet to come to a point where I find that all this overhead is useful. WPF seems really powerful, but it’s also really complicated and verbose to do anything at all. The overhead of adding a screen is huge: you have to create like a thousand properties, relay commands, events and events handlers, etc. I get that it’s the right way, but it’s a really long and windy way.

The main problem I have seems to be that people come up with incredibly complicated solutions to simple problems, and then say stuff like “it is easy to do X” and “simply do Y”… after posting a hundred-lines-long post with half a dozen classes… to display a message box.

As an aside, I hate Windows XP. In addition to being incredibly buggy (most of our customer’s problems come from XP users), it prevents us from upgrading to .NET 4.5, and using shiny new toys. It’s like we’re stuck in the dark ages. We have almost 10% of our customers still using XP. It’s huge! And about 40% of them seem to never update their software version, even though they are asked to do it at each software startup. That’s a bit depressing. We can’t use the C# async/await keywords, and more and more NuGet packages require this version. I can’t even find how to display a MahApps.Metro dialog box without the async keyword.