Cross-Platform Apps with Windows 8 and Windows Phone 8 – Presentation Materials

Thanks for checking out my presentation, “Cross-Platform Apps with Windows 8 and Windows Phone 8.” I hope you found it useful. Below is the code and slides I used. Enjoy!


Implementing Windows 8 Design Principles – Presentation Materials

Learning to develop for Windows 8 has been an interesting challenge. I hope my presentation helped you along your journey. I have made my presentation materials available for you to check out on your own terms.


WPF DataGridRow Double Click With MVVM

On my current project, we need to open a record for editing when the DataGridRow is double clicked. Unfortunately, the WPF DataGrid doesn’t support this functionality out of the box. There are, however, a couple ways to make this happen.

One way is to handle MouseDoubleClick event on the DataGrid. We are using Caliburn.Micro, so it is easy to get the MouseDoubleClick event to route to our view model. The view model can then assume that the selected item is to be edited. The problem with this is that double clicking anywhere on the DataGrid will trigger this event, including the scrollbars. That means that quickly scrolling down the items could trigger a double click and cause whatever item was last selected to be edited, which is unacceptable.

What we needed was to somehow handle the MouseDoubleClick event on each DataGridRow, make sure the one being double clicked on is actually selected, then call tell the view model to edit it.

I ultimately came up with two solutions. One uses a little code-behind and applies only to one case at a time. The other uses an attached DependencyProperty and is general enough to apply to all cases.

Using Code-behind

The code-behind solution may break the MVVM pattern, depending on your point of view. I feel that using code-behind makes sense in cases where you have logic that is specific to your how your view represents the UI.

First, you need to create the MouseDoubleClick event handler in the code-behind.

Next, you need the wire up each DataGridRow to use that handler for MouseDoubleClick events. You can do that with styling.

That’s it. This solution is pretty straight-forward. However, there are two problems with the code-behind solution.

The first problem is that this solution doesn’t scale. What I mean by that is that you have to re-implement it every time you want to use it.

The second problem is that it uses code-behind. As I said earlier, I believe the use of code-behind has its place. However, I prefer to stay away from it if I can.

Using Attached DependencyProperty

The attached DependencyProperty solution uses a helper class so that it can be reused across your application. It also assumes that your DataGrid’s DataContext is your view model. If that is not the case, you will need to modify it.

This helper class ties into the DataGrid’s LoadingRow event and uses reflection to find a specified method on the DataContext and execute it. All you have left to do is use it.

All you need to do is provide the name of the method on your view model to execute when the double click has occurred and the rest is taken care of.


While it’s unfortunate that WPF doesn’t provide this functionality right out of the box, it is not difficult to implement it yourself. Silverlight suffers from this same shortcoming. This solution won’t work as-is for Silverlight. It would need to be refactored into using Behaviors instead of an attached DependencyProperty.

I have posted a complete solution on github:

Happy coding!

Getting Dirty with Windows Phone 7 Presentation Materials

If you attended my presentation, Getting Dirty with Windows Phone 7, I hope you found it useful.  If you would like to play with the sample application I used in my demo, I have made it available on github:  I didn’t feel the need to post my slide deck.  However, here are the valuable links I had listed:
Tools, Quick Starts, Tutorials
Silverlight for Windows Phone Toolkit
Silverlight Unit Test Framework for WP7
Silverlight Multibinding
MVVM Fabric

If you attended my session, please take a moment to rate my presentation.

Fox Valley Day of .NET – March 5, 2011

St. Cloud .NET User Group – March 9, 2011

Twin Cities Code Camp 10 – April 9, 2011

Twin Cities Code Camp 11 – October 9, 2011

Getting Dirty with Android – Presentation Materials

If you attended my presentation, Getting Dirty with Android, I hope you were able to learn a thing or two.  If you want to review what I covered or play with the sample application that I worked with during the demos, I have made both available.

Slide Deck:
Sample Application:

If you attended my session, I would appreciate if you took a few moments to review it.

Twin Cities Developers Group, Feb 8th 2011

Chippewa Valley Code Camp, Nov 13th 2010

Iowa Code Camp, Nov 6th 2010:

WPF with MVVM: From the Trenches on dnrTV!

A few weeks ago, after presenting at CodeMastery, I sat down with Carl Franklin from dnrTV! to discuss WPF with MVVM.  The discussion is centered around the demo portion of my presentation entitled WPF with MVVM: From the Trenches.  This presentation is the precursor to the work I have done with MVVM Fabric.  Without further ado, check it out here: – complete with an un-flattering pic Winking smile

MVVM Fabric: Using a View Placer

A while back, I wrote about the navigation solution provided by MVVM Fabric.  I also wrote about using the ModalViewPlacer provided by MVVM Fabric.  In this post, I will talk about how to provide your own implementation of the IViewPlacer interface.


Since each application is unique, with its own unique UI, MVVM Fabric leaves it up to you, the developer, to provide the mechanism to place a view into that unique UI.  IVewPlacer is that mechanism.

An implementation of the IViewPlacer interface is required by the navigation solution provided by MVVM Fabric.  It will be used by the ViewController to place a view into your application when a request is made to navigate to a view.

A First Look

The IViewPlacer interface provided by MVVM Fabric follows the single responsibility principle.  Its only job is to place a view into your application, which you can see by looking at the interface itself.

When you implement IViewPlacer, you must provide an implementation for the PlaceView method.  The PlaceView method takes a ViewResult as a parameter.  So, let’s look at the ViewResult class as well.

As you can see, the ViewResult class has two properties.  The first property is the actual instance of the view, as created by the view factory.  This view will have a fully loaded view model and is all ready to make an entrance into your UI.  The second property is the ViewTargets value for that view.  There may be times where you need to place certain views in different places than the rest of the views.  With the ViewTargets property on ViewResult, you know what view you are placing and can act accordingly.

IViewPlacer Implementation

The sample application provided with the MVVM Fabric source has an implementation of the IViewPlacer interface.  We will be looking at a simplified version of that implementation.

The sample application has a tabbed user interface, so the view placer needs to take a view and place it into the TabControl used by the main view.  As you can see, it cycles through any existing views so that duplicates are not shown.  Then, if the view is not a duplicate, it is placed into the TabControl and given focus.

This is a simple UI, so a fairly simple view placer is needed.  More complicated UIs will likely need more complicated view placers.  As an example, a previous project I worked on used a docking solution similar to Visual Studio.  In that case, the view placer would need to be aware of what views go into what docking sections.


The IViewPlacer interface is integral to the navigation solution provided by MVVM Fabric.  Since each application’s user interface is different, it is left up to the consumer of the library to implement this interface.  The complexity of the view placer implementation is dependent on the complexity of the user interface, but placing the view is its only responsibility.

MVVM Fabric: Using a View Authorizer

A while back, I wrote about the navigation solution provided by MVVM Fabric.  In that post, I mentioned the interface IViewAuthorizer.  In this post, I will describe that interface and when to use it.


An IViewAuthorizer implementation is an optional parameter to the ViewController which, when provided, gives your application an opportunity to determine if a user is authorized to see a requested view prior to the view being shown.  If you do not provide an IViewAuthorizer implementation to the ViewController, the ViewController assumes that the user is authorized to see every view that is requested.

A First Look

First of all, let’s take a look at what the IViewAuthorizer interface looks like.

Pretty simple, really.  IViewAuthorizer has only one responsibility, to authorize views.  The AuthorizeView method takes a ViewTargets value as a parameter so it knows which view to authorize and returns a ViewAuthorizations enumeration value.  The ViewAuthorizations enum looks like the following.

The first option, Authorized, is self-explanatory.  If the view authorizer determines that the view is authorized, the ViewController will show the view.

The second option, NotAuthorized, is self-explanatory as well.  If the view authorizer determines that the view is NOT authorized, the ViewController will not show the view.  However, the ViewController will also throw an InvalidOperationException if the user is not authorized for a view.

The third option is for those more ambiguous situations where the view may be authorized, but it really shouldn’t be shown, yet you don’t want to throw an exception.  Let me give an example from my last project to help illustrate a situation where this is useful.

A DoNotDisplay Scenario

With my last project, there were views that depended on data provided by other views.  The other views had to be presented to the user so they could provide the data.  So, we had a situation where some views were prerequisites for other views.  Using the navigation solution provided by MVVM Fabric, it was easy to consolidate all the prerequisite checks in one place using an IViewAuthorizer implementation.

I developed a helper class that allowed me to specify which views were dependent on information from other views.  When the AuthorizeView method was called, the view authorizer would check to see if there were any prerequisites and, if there were, check to see if they were satisfied.  If they were not satisfied, the view authorizer would then request to show the view that will satisfy the prerequisite.  All that happens BEFORE the view that was originally requested was shown.  So, if the user cancels out of the prerequisite view before the prerequisite was satisfied, I did not want the originally requested view to be shown, but I also did not want the ViewController to throw an exception because the user opted to cancel the process before it could be completed.  So, I had the view authorizer return DoNotDisplay in that situation where the prerequisite was not met due to a user operation.


IViewAuthorizer provides you the opportunity to check whether a user is authorized for a view prior to showing the view.  It also provides you the ability to let the user gain the authorization to see the view prior to showing the view.  However, IViewAuthorizer is completely optional.  So, if your application has no need to prevent users from seeing any view, you do not need to provide an implementation for IViewAuthorizer.