Tech Tock

Time is of the essence.

Caliburn–Hasta la Vista

My Caliburn project is over.  A couple of thoughts.

I liked Caliburn Micro.  The best thing was that it makes it easy to connect events and methods — where you would normally use a DelegateCommand/ICommand and binding, now you get simple by convention auto wireup.  The worst thing is that using convention to autowire VM to View doesn’t show mock data in Blend for my favorite mock data objects which are subclasses of the VM, so I ended up using explicit bindings in the Xaml and not using a big benefit of Caliburn.

September 13, 2011 Posted by | Uncategorized | , , , | Leave a comment

Caliburn Micro–Soup to Nuts

Just getting into Caliburn Micro for a new Silverlight project.  I was a bit disappointed when I saw that the official cheat sheet was “coming soon”.  Rob Eisenberg made this excellent 9+ part Soup to Nuts tutorial and the Soup to Nuts section of the documentation has content, so the documentation for Caliburn is actually pretty good.  Of course, both these resources suffer from the death of the long form.  Once again I had to convert them to pdf so I could read them on the subway.  Maybe next time I’ll try this utility.

In any case, I’m excited to try out Caliburn Micro and my experience so far has been positive, but more on that later.

August 8, 2011 Posted by | Uncategorized | , , | Leave a comment

EventToCommand for Attached Property

To propagate events to a view to a ViewModel – use an attached property, not fancy xaml binding, but an attached property.  It says so right here in so many words.  So if you want MouseOver or DoubleClick, AutoComplete.Populating, etc. this is your answer.

Here’s the example everyone points you to.

The all purpose EventToCommand class in the MVVM Light Toolkit looks like the most convenient way to get this job done.

For any type of click, retemplating a button and using a ViewModel ICommand for its Command is the way to go.

August 6, 2010 Posted by | Uncategorized | , | 2 Comments

Visual Studio INotifyPropertyChanged Snippet

I just made my first Visual Studio snippet.  It’s really easy.

There’s a consensus developing that says dependency properties are usually too heavyweight and people are using INotifyPropertyChanged instead.  I miss the snippet that creates a dependency property, so I made a similar snippet for INotifyPropertyChanged.  You can download the code here.

To make a snippet, just go to Tools / Code Snippets Manager and find a snippet to start with.  I started with the “Define a Dependency Property” snippet since I was doing almost the same thing.  The Snippets Manager will tell you where that file is:


Go to the file system and copy the file to your My Code Snippets folder.  If you highlight the folder in the Code Snippet Manager, it will tell you where it is — you can copy the path from the location field.  The file is an xml file, but needs to be named “.snippet”.

Editing the file is very straightforward and the snippet will be available immediately – no restart needed.

One interesting thing about the code is that I’m using a simple method to do all the work:

I basically combined this CodeProject work with Jeff Yates object.Equals idea from here in order to handle both reference and value types in a single call:

Here’s how the snippet comes out by default (the myNames and type are the replaceable fields):

int _myField;

public int MyProperty
    get { return _myField; }
            ref _myField, ref value);

This is the method that does a check and notify in the base class:

protected bool CheckPropertyChanged<T>
      (string propertyName, ref T oldValue, ref T newValue)
            if (!Equals(oldValue, newValue))
                oldValue = newValue;
                return true;
            return false;

February 11, 2010 Posted by | Uncategorized | , , , , , | 3 Comments

From Winforms to WPF MVVM in 90 Minutes

Jason Dolinger made an excellent MVVM presentation last year.  It starts with a classic WinForms approach then upgrades it to a proper MVVM (Model-View ViewModel) pattern for WPF.  If you’ve ever created a WinForm app (even in VB6 – remember VB6?) and you’ve done your homework about WPF, this presentation will show you how to make a clean, properly separated and testable UI with MVVM.  I worked along with the presentation upgrading a small application I had written — that will take a bit more time, but it’s a great way to really learn.

More details here.

November 22, 2009 Posted by | Uncategorized | , , | 2 Comments



Get every new post delivered to your Inbox.