Extending supported properties set of a control

In my previous blog I mentioned that based on the questions from various folks, I saw two common usage patterns for extensibility.  I addressed the first pattern around “custom WPF control with good accessibility” in that blog. In this blog I will take the second pattern -

  • User has custom control which works fine with recorder and playback. However, the custom control has extra properties over the corresponding standard control and user wants to expose those.

In many ways, above is the simplistic scenario of the previous scenario or the Excel extension (refer series on Excel extension).

The sample for this is attached.  The sample extends standard WinButton control with WinButtonEx and few extra properties to this class.  In the sample, there are 3 files -

  • ExtensionPackage – The extension package as explained in the above mentioned series is the entry point that describes the extension.  Here it returns PropertyProvider instance as property provider.
  • PropertyProvider – The property provider for the WinButtonEx class. Again, the concept of property provider is explained in the above mentioned series.
  • WinButtonEx – This is the specialized class that is used by testers to get the extra properties.

With above details, comments in the code and some debugging on your own, you should be able to understand what is going on here.  Based on the various folks that have been asking about this, there is definite case to invest & simplify this scenario further.

WinButtonEx.zip