WPF ComboBoxEx

by Geert 22. October 2009 10:33

Some time ago, I needed a combobox in WPF to support an empty value (null), so the user was able to deselect or undo a selection. Unfortunately, this was not supported by the standard ComboBox class WPF offers.

Therefore, I decided to create my own combobox, with a “lot” of additional features that I think a combobox must support for a developer to be really useful. The attached ComboBoxEx class is the result, and it adds the following features to the standard ComboBox class:

  • Automatically select the value if only one item is available in the items source;
  • Support the MaxLength property when IsEditable property is enabled;
  • Keep selected value selected when updating the items source;
  • Disable the control when no items are in the items source;
  • Support an empty item, which can be null, but also a default value that can be specified.

A full demo application of all features is included in the package.

comboboxex

comboboxex.zip (34.12 kb) [Downloads: 695]

kick it on DotNetKicks.com

An advanced combobox for WPF that supports empty items, automatic item selection, maxlength property and more...

Tags:

C# | WPF

Pingbacks and trackbacks (4)+

Comments are closed

About the Author

Geert van Horrik is a independent freelance software developer since January 1st, 2007. Since then he was been working on several projects from C++ to C# (WPF, ASP.NET, etc). Currently he loves to write his software using WPF (or Silverlight if WPF isn't an option).

Lately, Geert is spending a lot of time on Catel, a free open-source MVVM Framework for WPF and Silverlight. Actually, it's more than "just" an MVVM Framework, it's a complete application library!