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

Zero To Phone Hero - Key points - part 1

I have just come back to Wellington after having spent a week travelling around and speaking at TechEd Australia and TechEd New Zealand...and of course CodeCamp in Auckland before TechEd.

Both TechEds were full of interesting people and interesting sessions. Not that I actually attended that many. But I assume they were interesting…

At both the aussie and kiwi conferences, me and Chris Auld showed off how to build an Azure backed Windows Phone 7 application in 60 minutes. And at both conferences, we promised to put up some blog posts around it. So here is my first one…one that talks about some of the key pieces that were shown. As well as some that weren’t shown…

More...

Phone Zero to Phone Hero in 60 minutes

As some of you might have seen/heard, I am speaking at TechEd New Zealand and TechEd Australia the coming two weeks. This is the reason for my blog being kind of quiet lately, I have just had a bit too much to do.

One of the presentations I am doing, is presented together with Chris Auld and is called "Phone Zero to Phone Hero in 60 minutes". It is a  "double feature presentation" with two projectors, two computers, two presenters and two applications. And at the end of the presentation, the two applications come together to form a Windows Phone 7 application backed by an Azure service.

We have finally got all of it built and up and running, so I thought I would give you a sneak peak of what is to come.

More...

A little warning about the hacked Windows Phone 7 image

I know that I possibly shouldn’t say this, but I downloaded the hacked WP7 emulator image and started using that while developing. Why? Well, I wanted to try out some of the OS integration that wouldn’t be possible with the regular emulator. So I did it…I admit it…

And it is kind of cool to be able to see more of the phone functionality in the emulator…even if I don’t have a touch screen. And to be honest, the interface gets a little clunky compared to the real thing with a touch interface when using a mouse…

But do remember that it is NOT the original image. So even if it looks as though it is just an unlocked version of the original image, it is actually a bit different. I haven’t found a lot of things that are different, but push notifications are unfortunately farked on the hacked version. It doesn’t throw an exception or anything. It just swallows the request for a new channel Uri.

I’m not sure if it is only me, or if it is like this for everyone running the hacked version, but it can be a thing to keep in mind if things aren’t working as they should…

Having that said, I probably should also mention that my computer has issues loading up the original emulator as well. It is VERY slow to start. Or rather, it starts quickly, but it takes ages for VS to deploy to it the first time. I think it might be due to some hardware issues on my machine or something, because I am not seeing the same issue on my office computer.

So I assume that this could possibly have an effect on the hacked emulator…but I haven’t been able to confirm this as I am not using the hacked version at the office…

Accessing Azure Development Storage from Silverlight

I have recently worked on several projects that have been built to utilize the Microsoft cloud platform called Azure. Azure offers a lot of really interesting benefits, and especially when it comes to being elastic. You can basically throw however much data you want at it, and as long as you are willing to pay for it, it will handle it. It doesn’t matter if you throw data at it that needs to be computed, or if you throw vast amounts of data that needs to be stored. Azure will handle it for you.

On top of that, it is really easy to build for. There isn’t really a whole lot to learn before one can get up and running in the cloud. Microsoft even offers a sweet SDK that gives you access to the cloud based services locally on your machine. It offers you the ability to deploy your webroles (web applications) straight to a local “cloud” and debug it. So you don’t even need to have an Azure account to starting to work with it.

More...

Windows Phone 7 InputScope in Visual Studio and Blend

Lately I have been working a bit on a couple of Windows Phone 7 apps, and I found a couple of interesting things along the way. I am going to try to blog more frequently soon, and try to cover as much of the interesting stuff as I can find. But it will have to wait until after TechEd New Zealand. But if you happen to be going to TechEd Australia or New Zealand, don’t forget to come to one of my talks and say hi.

Anyhow, the funky problem I am going to write about today is around a feature called InputScopes. On the phone, you can configure your TextBoxes to use different InputScopes. The InputScope defines which of the different software keyboards to use when writing in the TextBox. This is a really cool feature as it helps the user to write the type of info he/she is supposed to provide. It can be things like numbers or currency or chat. Each InputScope results in a different keyboard. Or at least some of them do. There seems to be more InputScopes than cool keyboards at the moment though…

More...

Windows Phone 7 Beta tools installation problem

A wee while back, I installed the new WP7 beta tools on my machine. I then started to rewrite the code for my push notification stuff to use the new beta APIs. And everything went fine until I pressed F5 to try and run it. At that point, it spewed out an exception saying

"Connection failed because of invalid command line arguments"

Apparently, I wasn’t alone to have this problem. A quick Google came up with several forum threads and interesting potential solutions.

The problem only arises if you had the previous phone tools installed and the reason is that he emulator creates a directory to store information in. Unfortunately, this directory isn’t removed when the old tools are removed. The good thing is that removing it fixes the issue. So if you run into the error message above, go to %LocalAppData%/Microsoft/ and delete the Phone Tools directory. Then restart the emulator, and it should be running nicely…

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

Windows Phone 7 Push Notifications Revisited

A couple of weeks ago…ehh…well…let’s at least call it a couple of weeks ago (it might have been longer to be honest) I posted a blog post about using push notification on the Windows Phone 7 platform. It included more or less everything you needed to start sending push notifications on the pre-beta version of the platform.

However, about a week ago (once again…+- a couple of days) Microsoft released the new beta version of the developer tools as well as the emulator. And I assume they also pushed I to the lucky bastards that already have phones.

In this new beta, they have changed the API for the notifications, and hence destroyed my previous code. So I have updated my sample to use the new tools and the new APIs. So here I go again…

More...