Microsoft CompositeUI Application Block

Originally posted on:

I started working on a new project a few weeks ago.  Were writing a new extensible Shell application with the Microsoft CompositeUI Application Block.  I haven’t used this block before.  Looks like Microsoft rushed this thing out the door.  Alot of needed functionality is missing, maybe the goal was to just provide a simple base shell layer and allow developers to extend it to do whatever.  I guess thats how it works when they are trying to release a new pattern or practice. 

So it took me a few weeks to wrap my head around this thing. ObjectBuilder was a new concept for me.  Pretty cool stuff though it turns out, Dependency Injection is a nice way of sharing global objects and making sure everything is referecing the right things.  Here some sample Dependency Injection Code.

Say you create a new object, and you want it to have a reference a global Selection Service..  all you have to do is add this code to your class:


public partial class PropertyGridToolWindow : UserControl, ISmartPartInfoProvider


   ISelectionService _selectionService;


   public ISelectionService SelectionService




   _selectionService = value;

   _selectionService.SelectionChanged += new EventHandler(_selectionService_SelectionChanged);


   get { return _selectionService; }


The cool thing about this, is instead of having to create an overloaded constructor to pass the existing instance of the Selection Service to the new object, Object Builder handles it all for you.  When creating the new PropertyGridToolWindow, just have ObjectBuilder do it:

PropertyGridToolWindow _propertyGrid;

_propertyGrid = ModuleWorkItem.SmartParts.AddNew<PropertyGridToolWindow>();

Thats it!  Object Builder will automatically set the reference to the Selection Service when the object is created.

I’ll post some more cool things I discover here as I go.


Leave a Reply

Your email address will not be published. Required fields are marked *