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...

Referencing class library projects with references from Silverlight application projects

One “feature” in VS2010 (and 2008 I assume) that bugs the hell out of me, is the way that referenced assemblies are packaged in Silverlight projects… And please let me know if you know of any fix for this!

Imagine that you have a solution with at least 2 projects. One Silverlight application project, and one class library project. The app project references the class library project as it contains functionality it needs. The class library project in turn references another assembly (or maybe more than one) that is needed for it to be able to run. This (or these) other assemblies are not default Silverlight assemblies, so they will not be on the target machine and needs to be included in the deployment… Unfortunately, this is where VS screws up…

More...

Using querystring parameters with the WebBrowserTask on WP7

I have just built a Windows Phone 7 app that is hopefully about to pop up on the marketplace within a couple of days. It is a fairly simple app, with very few impressive features. The most complicated part was to get the SQLite db used by the iPhone version of the app, to work on Windows Phone 7. Unfortunately I did not get SQLite to work on WP7. I ended up transferring the data to XML and adding some index tables, also in XML. But that isn’t the topic for this post.

The reason that I am writing this, is that I got stuck on a little thing while doing. Nothing complicated, but worth noting…

More...

Sharing resources and styles between projects in Silverlight

I have lately been working on a somewhat larger Silverlight application for a client here in New Zealand. The application is being built using PRISM, which means that it is loaded in a composite/ modular way. And with this modular/composite loading, being able to share resources between different modules becomes pretty interesting as it makes it easier to get all modules to share the same look and feel. So this got me to rehash a topic I have already talked about before, merged dictionaries.

This is obviously not a PRISM only thing to do, but it often becomes a little more sought after when the application starts getting spread out over several different projects… Luckily, it is very easy to share resources between projects in Silverlight.

More...

Finding and mitigating memory leaks in managed code using ANTS

A week or so ago, I got a call from a client who had some issues with an application that I had built. The application is a WPF 4 “media player” that is supposed to runs 24/7. The issue they were facing was that it only ran for about 12 hours before crashing. And at startup it used less than 100Mb of memory, and at the end (before crashing) it used about 1500Mb. So it clearly had a memory leak. And I needed to find it…fast!

And since this is the first time I have had to do this, I decided to share my experiences. Hopefully it will help someone…

More...

A Windows Phone 7 ComboBox

I am currently finishing off a tiny little WP7 application for a client here in New Zealand, which as such is not that very impressive. It seems like there is a LOT of apps on the way for the phone. I like it! At least the developers seem to have adopted the phone as their newborn child…or at least as a potential platform for future mobile apps…

But I am not going to be writing about that app. At least not right now. Instead, I wanted to write a little about something that surprised me. I have not been doing too much WP7 development. At least not the kind that includes a load of input controls. So I was kind of stumped when I found out that the phone does not have a ComboBox. Or rather, it does, but it doesn’t have a template suitable for the phone.

I found this to be rather odd, but could on the other hand understand that a ComboBox is probably not a control that is very well suited for a device like the phone. The OS itself seems to be using a list picker thingy instead, but that control seem to have stayed in Microsoft’s own control library and is not available. At least not that I have found.

So I guess the only solution is to do it yourself…at least after you Google it, which was what I did. I did find a couple of interesting ideas on how to style it, but they didn’t seem to follow the Metro style well enough to make me happy. Finally I found http://dotnet.dzone.com/articles/metro-style-combobox-windows, which got to act as the foundation for my control…

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...

Another user group meeting

Next Wednesday, October 20th, I will be presenting at the .NET user group here in Wellington again. This time the talk is all about smooth streaming (same talk as I presented at TechEd NZ). It covers everything from encoding your media, to publishing it on your server and of course also how to consume it from Silverlight. It will also be covering how to get your first live smooth streaming event going.

The talk does, as you can see, cover a wide array of things that has to do with smooth streaming. And to make it even broader, I will show off the Rough Cut Editor (an open source rough video editing tool built in Silverlight). And it would of course not be complete with out touching the cloud. So to finish it off, I will show you how you can deliver smooth streaming media out of Azure blob storage. A very cost effective and good way to share your media.

So if you are in Wellington, or close by, feel free to drop by if it sounds interesting. More information is available here: http://www.dot.net.nz/UserGroupPages/WellingtonNET.aspx

Audio recording and encoding in Silverlight

A while back, a client asked my company if we could help them with a feature for a web application they were using. They needed to make audio recordings online. Basically the application shows off users portfolios online, and offers the ability to add comments about their work.

So far, all comments and graces have been made using text. But now they wanted to move it into a somewhat more interactive solution, making it possible to record audio comments and thoughts about the users portfolio.

And obviously, being a Microsoft focused company, we came to the conclusion that this would be an easy thing to do in Silverlight. Especially since we all know that Silverlight in later releases gives us access to the users microphone and webcam. So this would be a piece of cake…or would it…?

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...