HelloWP7 Sample Functionality

Topics: Getting Started
Sep 6, 2011 at 3:35 PM

Howdy There,

I've been studying Caliburn for a few weeks now (hobbyist, time spread out heh), and I think it is awesome!  I love how it automagically works with bindings and commands, the Bootstrapper, the EventAggregator, Conductors...the works...It is freaking sweet. 

I just wanted to point out a very small tidbit about the HelloWp7 sample that I found ever-so-slightly boggling: When I clicked on the "Choose" button and selected a contact, it would show the message box that the result was OK, and that was it.  I don't know if this is the expected behavior, but I don't think so.  Eventually it dawned on me that the sample may be incomplete, and here is how I modified the TabViewModel.Handle method (**):


public void Handle(TaskCompleted<PhoneNumberResult> message)
      MessageBox.Show("The result was " + message.Result.TaskResult, DisplayName, MessageBoxButton.OK);
      if (message.Result.TaskResult == TaskResult.OK &&     //we did choose a contact
          !string.IsNullOrEmpty(message.Result.PhoneNumber))//that contact did have a phone number
        Text = message.Result.PhoneNumber;


Now when the Contact is chosen, it fills the Text property of the TabViewModel with the task's pseudo-callback data, the PhoneNumber.  And of course, since CM is awesome with bindings, this Text assignment is reflected in the bound Text control on the Tab View! 


**) Forgive me if this doesn't show up as code, I've never posted on CodePlex and the insert code doesn't seem to be working.  I've just added standard tags and I don't see a preview function to see if they will format the code properly.