Click here to Skip to main content
13,042,838 members (79,088 online)
Click here to Skip to main content
Add your own
alternative version


5 bookmarked
Posted 9 Jun 2013

How to Use Class System.Windows.Controls.ComboBoxItem to Implement a “Combobox with sub-list(s)”

, 9 Jun 2013
Rate this:
Please Sign up or sign in to vote.
Using certain properties of System.Windows.Controls.ComboBoxItem, we can “split” Combobox list in several “sub-lists” separated by special ComboBoxItem instances that play role of “separators”


In my tip, I described an approach I called a “Combobox with Most Recently Used sub-list”. It splits a Combobox content into 2 sub-lists - Most Recently Used Items and All Items.

Let’s see how this approach can be implemented in Silverlight.


To split Combox content into sub-lists, we need to display the “separators” between them – in our case (, these are the “Most Recently Used” and “All Countries” lines.

The class System.Windows.Controls.ComboBoxItem has the following properties that we can use to make a ComboBoxItem instance be such a “separator”:

  • IsEnabled: We set it to false and the item will become "disabled" – this is what we need for a “separator”.
  • HorizontalAlignment: We set it to HorizontalAlignment.Center and the item will become “aligned by center”, unlike the “regular” items aligned to the left.

So we insert two “special” items into the System.Windows.Controls.ComboBox.Items collection of a Combobox object.

One of them is a ComboBoxItem instance that has the following properties:

  • IsEnabled = false;
  • HorizontalAlignment = HorizontalAlignment.Center;
  • Content = "All Countries:"

And the second one has the following properties:

  • IsEnabled = false;
  • HorizontalAlignment = HorizontalAlignment.Center;
  • Content = "Most Recently Used:";

And here is the result – exactly what we need:

NOTE: Of course, this approach can be used not only to this specific task (a “Combobox with Most Recently Used and All Items sub-lists”); but to any task that requires to split a Combobox list to sub-list(s) by separating them with such “separators”.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
Belarus Belarus
I am a .NET and MS SQL developer. See my personal website

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 9 Jun 2013
Article Copyright 2013 by VictorSotnikov
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid