.NET Custom Control Resources
This is a growing set of resources for developers of custom controls, and will be initially focused on Windows Forms controls (for both regular .NET and Compact Framework), although at some point in the future, I will start including resources for WPF, Silverlight, and potentially also web controls.
Custom control development is a difficult and often frustrating endeavor, one that I’ve struggled with for the past couple of years. I’ve written a few articles on the subject on my own blog, and in addition to writing more articles there, I also want to draw your attention to other good resources I’ve found on the Internet in MSDN articles, documentation, and various blogs, as well as in a small collection of books that touch on the subject.
Normally I add links to resources in my blog articles for further study, and though I will continue to do so, I believe it will be helpful to start organizing these resources in a single place. If you know of any resources that could help clear the fog of confusion for aspiring control designers or elucidate the sparsely-documented details of Visual Studio extensibility surrounding custom designers, type converters, and the like, please leave a comment and I will add them to the list.
While it’s always nice to see working examples of custom controls and designers, I am especially on the lookout for information on pitfalls encountered along the path to making those solutions work. Seeing a goal achieved is great, but knowing how to work through problems on the way to your destination can be even more valuable. As I once heard a doctor say, “I could teach you how to perform an appendectomy in about 45 minutes, it’s really not hard; but it would take many years to teach you what to do in case something went wrong.”
As an example, I renamed one of my custom controls, and suddenly the forms on which I had put instances of this control wouldn’t display in the designer, and instead I got error messages telling me that specific properties weren’t available on UnsafeControl. The answer was that I had forgotten to update my .xtma file–the design-time attributes file used for Compact Framework doesn’t get included in the Rename refactoring, and without the DesktopCompatible=true setting, it determined that my control was unsafe and thus gave the error. This is a simple example, and many are much more complicated, so it’s important to create an awareness of the many tricky issues that may come up that are unique to custom control development, in the same way that we train ourselves to recognize exception messages and relate them to their common causes.
- Using Extension Methods to Manipulate Control Bitmaps in Compact Framework
- Compact Framework Controls (Part 1): Creating Custom Controls and Designers
- Compact Framework Controls (Part 2): Polygon Clipping
- Compact Framework Controls (Part 3): Linear Gradients
Blogs & Other Articles
There are a handful of kind folks out there who have shared their experiences and knowledge of several custom control topics. Sometimes it’s these blog articles that provide the most approachable view of the subject.
- Amr Elsehemy has 18+ articles under the category Design Time Support on his blog.
- Mooseworks Software shows off a very nice graph control using many techniques, including custom editors, the designer serialization attribute, and more.
- Kondanda Pani demonstrates UITypeEditors, TypeConverters, and Designers.
- Victor Boba explains custom container controls.
- An MSDN article explains a basic transparency effect in a Compact Framework image button control.
- James Simms demonstrates painting of several graphic effects in a single (and very nice-looking) button control.
There are a few websites devoted to building .NET user interfaces, custom controls, Windows Forms, WPF, etc.
Microsoft Connect Suggestions & Bug Reports
There are some things that, if added to Visual Studio or the .NET Framework, would simplify or otherwise enhance the custom control-writing experience; and there are bugs that, if fixed, would do the same. Here are some that I’ve either discovered on Microsoft’s Connect (feedback) site, or have submitted myself.
- 339898 – Provide validation of .xtma file contents for Compact Framework custom control projects.
- 339896 – Update .xtma file contents when a Rename refactoring is executed on control class or class member names (properties, events, etc.)
I have many more links and resources, so please bear with me as I update this page. I’ll be reading through the Microsoft Connect suggestions and bug reports to find the custom control and designer gems, and will continue in my research of blog articles and other websites, as well as podcasts and other media formats.