Geeks With Blogs
Gavin Stevens's Blog the ramblings of another developer....

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.


Posted on Wednesday, December 27, 2006 7:55 PM | Back to top

Comments on this post: Microsoft CompositeUI Application Block

# re: Microsoft CompositeUI Application Block
Requesting Gravatar...
Have you checked out the Smart Client Software Factory? It extends the CAB and provides a framework to utilize MVP/MVC frameworks. Check out my site I have two links for setting up and creating views in the SCSF/CAB World of MVP/MVC.
Left by Adron on Dec 29, 2006 6:36 AM

Your comment:
 (will show your gravatar)

Copyright © Gavin Stevens | Powered by: