Building a template selector in Silverlight

There are several “missing” features in Silverlight that people keep bringing up, or keep trying to find solutions for. One of them is the template selector, or DataTemplateSelector class to be more specific.

The DataTemplateSelector has a single responsibility, which is the way it should be. It is responsible for returning a DataTemplate based an object. Generally, it is used in lists, where the data template can be selected based on the bound item, and thus give different templates to different kind of objects in the list.

In Silverlight, this is not possible out of the box, and instead requires us to create multiple UI controls, and hide and show them using data binding. This approach works, but it easily becomes heavy and complicated, which is why I want a template selector that works…

More...

Trying Out Azure Service Bus Relay Load Balancing

As you might have noticed from previous posts, I am somewhat interested in the Azure Service Bus. Why? Well, why not? To be honest, I don’t actually know exactly why, but I feel that it offers something very flexible out of the box, and without to much hassle.

One of the later feature that was added to it is the support for load balancing when using message relaying. (You can read more about message relaying here)

It is pretty cool, and just works… And by just works, I mean it really just works. If you have a service using message relaying today, adding another instance will automatically enable the feature. But remember, the messages are delivered to ONE of the services, not both. So if your service cannot handle that, make sure you change the implementation to make sure that only one instance is running at any time.

More...

Encryption is not everything

Sorry, for the cryptic title for this post, but it is sort of true, at least when it comes to client access policies. And I didn’t know it until a couple of days ago…

As a part of a project I am working on, we are deploying an STS (Secure Token Service) to handle authentication the users of an OOB Silverlight application. The STS is completely decoupled from the application, as it should be, and is hosted on its own, and the client requests a token from the service through a simple HTTP GET with basic authentication.

More...

Exposing and consuming REST-based APIs with WCF WebApi and Silverlight

There are many ways to expose functionality and data from a server to a client. And there is probably almost as many going the other way… In Microsoft scenarios, using WCF is the obvious choice for most of us, and when people talk WCF, they generally talk SOAP based webservices.

SOAP can however be a less than ideal choice in a some cases. It is way more complicated than some of the other options, and on top of that it has a tendency to bloat the messages being sent, which can be an issue when working with mobile clients for example.

More...

SignalR and Silverlight

SignalR is a somewhat newish open source project that makes it possible to simulate push notifications on the web. It does so using long-polling (websockets available as an extra download), so it isn’t true push as such, but it gives the appearance of push. And on top of that, it is so ridiculously simple to set up…

Unfortunately, the NuGet package for SignalR doesn’t include the Silverlight client, which the GitHub project does. This is most likely going to be fixed in the near future, but currently you will have to do it the manual way instead of using NuGet.

The server part of SignalR works fine through NuGet, however, it doesn’t play nice with the Silverlight version as a property has been renamed and causes issues. So we have to do the whole thing manually to make sure both the client and server has the modified property… Once again, it is probably going to be fixed some time really soon.

More...

Adding WCF custom service behaviors in config

Lately I have been working with a bit of WCF for a client, and one of the things I have had to do is to create a service behavior to handle some security things. However, due to the fact that this application needed to run in several different environments, it needed to have different configuration under different circumstances.

The real need was actually to be able to remove the behavior in some circumstances, and add it in some. But I didn’t really want to do it through a bunch of if-statements in my behavior. Instead I wanted it to be done through configuration so that I could turn it on and off using config transforms…

More...

Is Windows Phone 7.5 Too Good?

I know I am a Microsoft fanboy, and I am the first to admit it. But I still want to say that I can listen to other peoples arguments and try to look at the facts objectively. I tend to see benefits in a lot of Microsoft things, but that doesn’t mean that I believe that everything else sucks.

I have used a Windows Phone device since before they were even released, built a couple of apps for it and talked about it for different audiences. And it is not a big secret that I like it, especially since I got Mango on my phone.

Having that said, I still believe that there are 2 very good alternatives available. The iPhone is, whatever kind of fanboy you are, a great phone. No, I don’t like a lot of things when it comes to Apple, and I don’t like being stuck with iTunes, and I don’t like Apple’s censorship. But it still is a freaking awesome phone, and pretty much single handedly managed to change the smartphone market into what it is today, which is SO much better than it was with Windows Mobile.

More...

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!

Developer/Designer Workflow According To Me - Take 1

A question I keep running into when I speak about XAML-based application developer is how the developer/designer workflow should work. I don’t know if the question is common in general, or if it is because people feel that I’m not only passionate about coding, but also about design.

I have spent quite a lot of time thinking about how this workflow should work when working with XAML. In other technologies, I believe that the flow is much harder to get going, and I believe it requires more steps. In the “XAML world”, it should be a lot easier. The separation between functionality and design is pretty clear. And this separation should enable quite a well working flow.

Before I get into how I see it, I want to add a disclaimer… I have not been able to try this out in the real world as much as I would have liked. Mainly because I, in most cases, play all the roles. Or at least manage everything from XAML to code, with visuals coming from a designer.

More...

Implementing federated security with Azure Access Control Service

I believe it is time for a really heavy blog post, and if you have ever read one of my other blog posts you are probably getting scared now. My posts are normally big, but this might actually be even bigger… Sorry! But it is an interesting topic with many things cover…

But before we can start looking at code, there are 2 things I want to do. First of all, I want to thank my colleague Robert Folkesson (warning, blog in Swedish) for getting me interested in this topic, and for showing me a great introduction.

And secondly, I want to give a quick run-through of what federated security and claims based authentication means…

Federated security means that an application relies on someone else to handle user authentication, for example Windows Live or Facebook. These identity providers are responsible for authenticating the user, and returning a token to the application, which the application can use to perform authorization.

More...