Problem adding ComboBoxItems

Dec 9 2010 8:41 AM
Hi,

I am trying to create and add some ComboBoxItems to a ComboBox.

foreach (var type in deviceTypes)
{
ComboBoxItem cbi = new ComboBoxItem();
cbi.Content = type.TypeName;
cbi.Tag = device.ID;
devicesComboBox.Items.Add(cbi);
}


The problem is that the ComboBox displays a lot more info than I'd like to:

ComboBoxItem shows a lot more info

How can I make it display only the 'Personal Computer' part?

I know there are other ways to add items to a ComboBox but I need every ComboBoxItem to store two values: a string value to show in the ComboBox and an int value which I store using the Tag property. I need this int value for further use so unfortunately ignoring it is not an option.

So... is there any way to properly display the ComboBox items?



Answers (4)