Launching Dialog Windows in Managed MMC Snapins

Launching a child window inside MMC 3.0 from managed code isn’t easy.  Different APIs are required for different circumstances.   I don’t know exactly why this is, but I assume it has something to do with all the tricks MMC does to give each managed snapin its own UI thread, and needing to marshal a…

0

WPF ICommandSource Implementations Leak Memory!

Actually the title of this article should be entitled “How to use WeakEventManager with ICommand implementations”, but the memory leak title is more exciting (and true) Overview Some WPF controls, such as Buttons, are command sources.  A command source has 3 properties, Command, CommandParameter and CommandTarget.  When the control does it’s action (like Click for…

3

WeakEventManager and IWeakEventListener

When my team first starting hitting “memory leaks” due to event handlers we investigated a variety of solutions.  There are many examples on the web for implementing some kind of weak listener – but interestingly almost all of them have some flaw.  In the end we settled on using WeakEventManager and its associated IWeakEventListener interface….

5

Creating Attached Properties And Services

One cool thing about DependencyProperties is the ability to have AttachedDependencyProperties (or Attached Property for short).  Regular properties are defined on a type and exist for instances of that type and sub-classes.  An Attached Property is defined in one type, but can be applied to any instance of DependencyObject. So how does this work?  Well…

1

Performing Bulk Modifications To a Databound Collection

On a WinForms project in the past we were working on scalability and performance.  One of the things we discovered was that individually invoking items to the UI thread was a bottleneck. The theory is that the each time one does a BeginInvoke it adds a message to the Message queue.  This adds overhead.  If…

1

AddRange and ObservableCollection

The Issue Recently a friend asked a question about ObservableCollection.  The question was how to do an “AddRange” method on it. The obvious answer is, of course, just write a method which iterates over the input collection and calls Add for each.  But this really isn’t the answer, because the question really isn’t about AddRange…

3

Developing Reusable Controls with the Model-View-ViewModel Pattern

There have been several great blogs and articles about the Model-View-ViewModel pattern lately.  I thought I would share my own example and thoughts on it – specifically on using this pattern to develop reusable controls. Rather than re-explain what the Model-View-ViewModel pattern is I suggest you read these other articles.  I recommend ·        http://msdn.microsoft.com/en-us/magazine/dd419663.aspx ·       …

1

Mouse vs Keyboard and ContextMenus

Recently I was asked to modify one of my controls so the user of the control could get the proper placement of thier context menus.  My intial response was for them to use the placement properties on the ContextMenu/ContextMenuService to achieve the right positioning. Then the real issue came out.  They wanted different positioning based…

2