Code from my MVVM presentation at DevSum14

During my MVVM presentation yesterday, I promised to upload the code to my blog. So here it is! Go ahead and run the application, put some breakpoints in there and see what is actually happening. It should give you a good baseline for a simple, and small “pay for play” MVVM framework. And if you have any questions, Just ask them in the comments, or via e-mail or Twitter…

Download: FiftyNine.MVVM.zip (517.57 kb)

Developer Mania II

I have just returned from the Developer Mania II conference that I spoke at today. It was a great one-day Microsoft conference about Windows Phone 7 development, and I heard some good speakers.

My part in the conference was to share the stage with Johan Lindfors and talk about MVVM. As a part of that talk, I showed off some code I have created to simplify navigation in MVVM scenarios. I thought I would share that code, so here it is: DeveloperMania.MVVM.zip (628.26 kb). It is a little on the heavy side, but that is due to the inclusion of Unity…sorry!

Code from my presentation at the NZALM conference

Earlier this week, I had the pleasure of presenting at the NZALM conference here in Wellington. Even though it was an ALM/Visual Studio conference, there was a “lot” of MVVM talk.

I did one intro session called “MVVM – The Naked Truth” and one deeper one called “MVVM – Going Beyond Hello World”. Both sessions went well according to me, but on the other hand I might be a bit biased… Hopefully the attending people would agree with me, but you never know.

As part of the talks, I did both write and show some pre-written code that I promised to put up here on my blog. So here it is:

MVVM - The Naked Truth.zip (18.88 kb)

MVVM - Going Beyond Hello World.zip (333.08 kb)

I also mentioned another blog post that would contain even more code samples. And since the search functionality on my blog for some reason is broken (I think it has to do with a new engine version with old theme…), I thought I would link to it from here instead. So here it is: https://chris.59north.com/post/SLAMD-session-code.aspx

If you have any questions about the code, just give me a yell or drop a comment and I will help out as much as I can!

Removing Design Time references at compile time

As you might have noticed on my blog, I like working with Silverlight, and I like using the MVVM pattern when I do so. As a part of this, I generally create design time ViewModels to get the best help from the tools (VS and Blend). VMs

The annoying thing about this, is that project containing the design time information need to be referenced by the application for the whole thing to work. But when the app is built and released, I really don’t want the extra ViewModels to be included in the xap file. I guess, in most cases, they are fairly simple and small, making the xap bloat minimal. But it still feels wrong. And it feels even worse when your design time VMs become large due to embedded resources such as images and data…

More...

MVVM and animation, revisited

A while back, quite a while back to be honest, I wrote a blog post about using animations in the MVVM pattern. And even if the way of doing it mentioned in the post still works, I would not recommend using it.

Adding the animation support in the way that that blog post says, will couple your VM to the StoryboardManager. Not that this really matters, as it will still be quite testable and so on. But it feels wrong…and I don’t like things that feel wrong…

In this post, I aim to cover a couple of ways that we can trigger animations and state changes based on the VM. And yes, these techniques have been hashed and rehashed on several other blogs, and you might already have read about it, but I still have people come to my blog to read the old post. So apparently it is still an issue for some…

More...

Data binding images with MVVM

The title for this post make it sound like the world’s simplest thing. And to be honest, it sort of is. It is not hard to get images from the ViewModels into the view, but there are several ways of doing it. Each with its own pros and cons.

In my world, my VMs often get urls/uris to images instead of the actual image. The reason for this I guess is sort of the same thing as why you shouldn’t store your images in the database. The models can become huge if they include the images, especially if we add a couple different image sizes and so on. And that is without considering the possibility of us transferring a whole array of these objects across the wire. And in a lot of cases we don’t even show all the images in the UI, so why would we pass the images along if we don’t need them…

More...

MVVM and “restricted” functionality

So, I am back with a new post after WAY too long. It got really busy around TechEd Aus and NZ, and I really thought and hoped that I could get back and become active again as soon as that was over. Unfortunately, pushing work in front of you doesn’t really clear it…so when I finally got back from Auckland, I had a whole pile of things to do…

Anyhow…enough with the excuses…get to the topic already! So the topic is how to handle commanding with “restricted” functionality. There is two things in that sentence that I want to clarify. With commanding, I mean move functionality from the view into the viewmodel and removing as much code as possible from the code behind of the view. And with “restricted” functionality, I mean the type of functionality that cannot be handled anywhere but in the code behind of the view…

More...

The power of MVVM…

Everyone, and by that I mean anyone that has been coding for more than a year, talks about decoupling and layers. It’s all about building an n-tier architecture, and about decoupling the layer so that they can be changed later on.

And however much I understand this, and like it, and use it, I still argue that it is sometimes overkill. And even though I definitely can argue both sides of this topic, I am not even going to get started doing so. Maybe I will in a later post, when I feel like getting flamed… :)

This post is about how decoupling your view from your view logic using MVVM can really be helpful. And I am not going to talk about how unit testing will help or anything like that. I am going to explain why MVVM is more important than just testing by showing an example…

More...

Code for the SLAMD session tonight

Tonight, I presented a talk about MVVM “in the real world” at the Silverlight and Mobile Developer user group on Wellington.

For those of you who were there, I am sorry that it wasn’t better organized. I just ended up with way too much work the last 2 weeks, so I didn’t have enough time to structure it all enough. I decided that it was more important to get the code built than to have a  lot of PowerPoint slides.

As I did promise, I you can download the code below and I have also added the IDispatchService that I talked about as well. It will give you the ability to marshal execution back to the UI thread from a ViewModel. Just call IDispatchService.BeginInvoke() and pass in a lambda expression or a method to execute on the UI thread.

For those of you who weren’t at the user group, or were there and thought that what I said was completely impossible to understand, I just want to explain what is in the download.

More...