Navigating in Windows Phone 7 using Caliburn Micro

Everything must be shocking to new developers who haven’t used a framework and has been following the traditional way of developing applications in Windows Phone 7.

In this post, I will teach you how to code from Traditional way to Caliburn Micro way.

Assuming we have a MainPage.xaml which contains a button that just simply navigates us from MainPage to Page1.xaml.

The basic way to do this is by adding a click event on our button and then saying that

NavigationService.Navigate(new Uri(“/Page1.xaml”, UriKind.Relative));

in Caliburn Micro, since the PhoneApplication Class is abstracted away from us, we have no idea if its still the same. Our bootstrapper is inheriting from it and assuming we registered our ViewModel in our IoC Container, then we could probably say that,

public void GotoPageTwo() {
.WithParam(x => x.NumberOfTabs, 1)
.WithParam(y => y.PageName, “leo”)

So what benefit did I get, not only was the code readable but it has a extension methods that can support lambda expressions which we cannot do in traditional way. We could have a longer line of code just to pass a parameter. And did I forgot to mention that you don’t need to do much Binding your your commands? I think I did not, but like I said, before you need to either brute force and just double click the button or create a property and bind a command into it.

In Caliburn Micro, I could just simply say

<Button x:Name=”GoToPageTwo” />

and behind the scenes, it automatically binds the command whether its a delegate or composite command it is supported.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s