Pivot Video, now with NDC 2011 conference videos.

I’ve updated my Pivot Video code to include NDC 2011 Videos, plus a couple of bug fixes!

It includes the WMV streams for NDC 2011.

One of the things I’ve done is separate the xml by conference as well as an “all” xml file (DiscConf.xml). This way you can load just your favorite conference or all of them.

Download Pivot Video now.

Download all conference XML files now.

Pivot Video, now with TechEd 11 goodness!

I’ve updated my Pivot Video code to include TechEd 11 Videos, plus a couple of bug fixes!

It includes the WMV High streams for TechEd11.

Download Pivot Video now.

MVVMT4 v1.1 released

MVVMT4_200x200I’ve released version 1.1 of my open source project MVVMT4 today.

It uses T4 Templates for generating view models, and views for WPF, Silverlight, Windows Phone using T4 Toolbox and MVVM Light

On Nuget! Type in "Install-Package MVVMT4"

Now in version 1.1: Conforms to StyleCop rules, and optional Unity DI container for ViewModels.


Pivot Video, now with Mix 11 goodness!

I’ve updated my Pivot Video code to include Mix 11 Videos, plus a couple of bug fixes!

It includes the WMV High streams for Mix 11.

Download Pivot Video now.

Reference paths in visual studio

When you add a reference to a .dll in Visual Studio, there are a couple schools of thought.

One way is putting a lib folder inside the project.


Another method is to used a share to store references. e.g.


Someone mentioned to me today that they got out-voted by other people who were voting for the share reference method.

There are a couple of reasons this approach is bad:

  1. If the files are moved or deleted, it will break the build for every existing app.
  2. If the share is unshared, or there is network issues, the build will fail.

If you go with the Project\lib folder in the project approach, it has none of those drawbacks. You can still store the references on a shared drive, but copy them to the Project\lib folder. This will not have the any of the cons of the shared UNC path approach. Plus, the Project\lib approach is more accepted among development teams.

This is just my opinion… Thoughts?

Pivot Video

Sometimes you just want to watch a programming conference session video, but they are all over the place. PDC 09, PDC 10, Mix 10, three difference sites / urls. I wrote a little WPF program that allows you to select videos based on multiple criteria similar to the PivotViewer ™ control.


You can select by presenter, conference, tags, or even search. You can play the results in a playlist, shuffled or not, and even save the playlist for later.

Pivot Video will show you a tooltip with more information when you mouse-over a session. It’s also optimized for touch screens and touch scrolling.


It currently has conference videos from:

  • Mix 2010
  • NDC 2010
  • PDC 2009
  • PDC 2010
  • Tech Ed 2010
  • Tech Ed AU 2010
  • Mix 2011

Download Pivot Video

kick it on DotNetKicks.com

Shout it

Using MEF to link view model locator and load assembly UIs dynamically

UPDATE 01/28/2011: I cleaned up the T4 templates and made it prettier. Re-download the source code!

So I decided I wanted to create a WPF navigation application. I was definitely inspired by Billy Hollis’ StaffLynx application.

The application has to have the following requirements:

  1. ViewModelLocator must be dynamic, and the parts satisfied by MEF, including UI Extensions.
  2. UI pages in separate assemblies will load based on pack Uri syntax.
  3. UI extension dlls cannot know about the main app, and vice-versa. e.g. No direct references.
  4. UI Extensions have to be loaded from the ProgramData folder, because applications cannot write directly to the Program Files folder.
  5. Must use my favorite MVVM Framework MVVM Light. Although you could customize this for any MVVM framework.
  6. Must work in Expression Blend.



I wanted to use a frame for navigation, and have the buttons populate and navigate automatically. The buttons would show icons of the UI Extensions too.



How this came about


I started out looking at Glenn Block and John Papa’s implementation of a dynamic view model locator using MEF. But that was Silverlight, and couldn’t be ported easily, due to functional differences in the API from Silverlight to WPF.

But then I stumbled on Glenn Block’s WPF version of the Silverlight APIs sort-of as a companion to the WPF version of MEF API. The problem with that API is it loads extensions from the Program Files folder.

I also wanted each extension to have their own folder. I had already written a MEF helper class that would read assemblies from the ProgramData folder, so I decided to go for it. Snippet from the Compose() method in my MEF Helper:

Code Snippet
public void Compose()
    AggregateCatalog Catalog = new AggregateCatalog();

    // Add This assembly's catalog parts
    System.Reflection.Assembly ass = System.Reflection.Assembly.GetEntryAssembly();
    Catalog.Catalogs.Add(new AssemblyCatalog(ass));

    // Directory of catalog parts
    if (System.IO.Directory.Exists(ExtensionsPath))
        Catalog.Catalogs.Add(new DirectoryCatalog(ExtensionsPath));
        string[] folders = System.IO.Directory.GetDirectories(ExtensionsPath);

        foreach (string folder in folders)
            Catalog.Catalogs.Add(new DirectoryCatalog(folder));


    _Container = new CompositionContainer(Catalog);

The UI and the UI Extensions both reference the Shared Contracts, so I had to put the view model locator in there.

I then found a semi-usable solution in the article Blendable MVVM ViewModelLocator using MEF. So I “stole” the View Model Locator from there, with some modifications, and porting it to VB.NET as well.



This version of the View Model Locator does not share much similarity to the John Papa version, because it uses the .NET 4.0 DynamicObject. This was the magic to bind the data context to the view. Basically, if you inherit DynamicObject, you can override the TryGetMember method, and resolve a property that doesn’t really exist.

Code Snippet
public override bool TryGetMember(GetMemberBinder binder, out object result)
    string name = binder.Name;
    if (!dictionary.TryGetValue(name, out result))
            if (ViewModels == null)

            dictionary[binder.Name] = (result = ViewModels.Single(v => v.Metadata.Name.Equals(name)).Value);
            return result != null;
        catch (Exception ex)
    return true;

The app turned out like this:


I know, I know, the UI is not pretty, and it’s not meant to be. It’s a beginning for you to start with. The buttons at the bottom are loaded dynamically using an ItemsControl and MEF. When you click on a button, it fires the NavigationCommand, to navigate to the Uri of the UI Extension. I created interfaces for UI Extensions:

Code Snippet
public interface IUIExtension


public interface IUIExtensionDetails

    string Category { get; }
    string IconUri { get; }
    string Name { get; }
    string Uri { get; }

    int SortOrder { get; }

And then I created a custom attribute that exports the classes via MEF:

Code Snippet
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class UiExtensionAttribute : ExportAttribute

    public UiExtensionAttribute()
        : base(typeof(IUIExtension))

    public string Category { get; set; }
    public string IconUri { get; set; }
    public string Name { get; set; }
    public int SortOrder { get; set; }
    public string Uri { get; set; }

Creating a model for that is simple:

Code Snippet
[UiExtension(Name = "Settings",
    Uri = "pack://application:,,,/MefMvvmSample;component/View/SettingsView.xaml",
    IconUri = "pack://application:,,,/MefMvvmSample;component/Resources/InternetSettings.ico",
    Category = "Settings", SortOrder = 0)]
public class Settings : IUIExtension

In the view models, you only had to add the ExportViewModel line:

Code Snippet
[ExportViewModel("Settings", false)]
public class SettingsViewModel : ViewModelBase

Then it gets wired up automatically. The XAML is pretty much the same for binding the locator:

DataContext="{Binding Path=PageOne, Source={StaticResource Locator}}"


The Shared Contracts dll has to be signed with a public key, because it will be in the extension folder as well as the normal program folder. This way, it will only load once. If it is not signed, it will attempt to load it twice.

The postbuild.cmd batch file copies the built UI Extension to the Extensions folder. This is the folder it is expected to be in. If you change the product name of the main UI, you have to change it here in the postbuild.cmd too.

Other useful classes



App commands are a static class with strings for navigation, closing the window and the main window name.

Code Snippet
public static class AppCommands

    public const string Navigate = "Navigate";
    public const string Close = "Close";

    public const string MainWindowName = "MainWin";



This class saves and loads the windows dimensions and placement on the screen on initialization and closing.

Code Snippet
private void MainWin_Closing(object sender, System.ComponentModel.CancelEventArgs e)
    SerializeWindowState.SaveWindowState(this, MyApplication.AppInfo.Info.ProductName);

private void MainWin_Initialized(object sender, System.EventArgs e)
    SerializeWindowState.LoadWindowState(this, MyApplication.AppInfo.Info.ProductName);



This class was needed because I wanted to have a default icon to fall back on if the UI Extension did not specify a icon Uri.

Code Snippet
public class IconConverter : IValueConverter

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        if (value != null)
            return value;
        return "pack://application:,,,/Resources/Document.ico";

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        return value;


T4 Code Templates


I’ve included T4 code templates that generate pages, windows, and user controls that require only a little modification. These enable you to generate the view, and view model quickly. They work with WPF, Silverlight, and Windows Phone.

They have the following features:

  • Navigation messages sent using the Messenger in MVVM Light.
  • How to close a main window from a view model or another view using close messages.


OK Already! Where’s the download?


Download the C# code here

Download the VB.NET code here

kick it on DotNetKicks.com

Installing a virtual network from scratch for developers

I had the opportunity recently at work to install Windows Server 2008 R2 from scratch and setup several virtual machines in a network configuration, and here’s how I did it.

The physical machine has 16 GB memory, and is a dell desktop machine actually! It has 4 cores, but with hyperthreading it shows 8.


Being a software engineer and all, we don’t often get the chance to set up an environment like this from scratch. This was fun, but I’m not a network engineer.


If you only have one network connection on your physical server, make sure you bridge it with the virtual adapter too. Then set the settings on the bridge and not either adapter.


To open ports on “Windows Advanced Firewall”, open a command window as an administrator. Issuing the following command will open port 80 on your firewall for you.

netsh firewall set portopening TCP 80 "Web"

TFS 2010 and SQL Server 2008 R2

Installing both of them on VMs was fairly easy, and fault free, if you follow their install guidelines. Thank goodness too! because TFS 2008 took me 2-3 days… This took less than a half a day.

I have TFS installed and working on two ports, since 8080 is a typical router remote admin port, which is already mapped, and cannot be forwarded outside.

There was a couple gotchas along the way that I needed to refer to blog posts to fix. One is with SharePoint.

You cannot install SharePoint from the Roles. If you do, you still have to download a patch .msi and install that.

Also, to get to create a site in SharePoint (so TFS can use it) you have to run IE as an administrator, and then the “Create a site” link will be visible.

Not to mention the whole “IE Hard Admin” which locks down IE on the server. You have to constantly add the local sites into the trusted sites too.

Exchange 2010

This was a BEAST to install! Really! I ended up installing it twice, both times using only the GUI to install and configure it, with the updates too.

DONT: “Don’t delete your user account from exchange or any other account as it deletes it from the active directory too. I hosed the whole setup that way and had to install all the virtual machines as well as install windows again on the server.

Also, when you install windows, before connecting to a domain, create a user with admin rights, since joining the domain seems to not allow the administrator login to login.”

I installed a SSL certificate for the external access, but internally it still says the cert is invalid, because it’s a local domain, and I now need a ssl cert for the internal one too.

I still haven’t finished the exchange correctly to get it working inside and out. I guess I’ll figure it out later…

EF4 T4 Templates

I just started my first open-source project. EF4 Templates. Yeahhh!

EF4 Templates uses T4toolbox to generate POCO self-tracking entities that can be unit tested, along with validation for WPF, Silverlight RIA services and ASP.NET/ASP.NET MVC. They also generate an ODATA service with authentication for usage with WPF.

Some of the features already implemented:

Self-tracking entities that use IContext and IObjectSet so they can be seperated from EF, and unit tested.

Fake object context for testing purposes.

OData service endpoint for use with WPF or windows forms, including forms authentication.

Validation using sidecar classes like RIA services and DataAnnotiations. A special class is generated for WPF to use DataAnnotations too.

Some of the new features I wish to implement are:

Silverlight domain service with OData endpoint

Right now the templates generate VB.NET code but I soon hope to have more converted to c# too. Wanna help?


Xaml color scheme generator

I’ve made a xaml color scheme generator that works with http://colorschemedesigner.com/

It generates a resource dictionary and xaml demo source. In the color scheme generator site, just export to xaml, and save to a file. In the generator, browse for that file, and click convert.

Download it here

Requires .NET 4.0 Client Profile.