WPF - add static items to a combo box

Unknown Coder picture Unknown Coder · Nov 24, 2009 · Viewed 111.4k times · Source

I've said it before and I'll say it again, the easiest examples for WPF are also the hardest to find on the web :)

I have a combo box that I need to display but it doesn't need to be databound or anything else, the content is static. How can I add a static list of items to my combo box using XAML?

Answer

Wade73 picture Wade73 · Nov 24, 2009

Here is the code from MSDN and the link - Article Link, which you should check out for more detail.

<ComboBox Text="Is not open">
    <ComboBoxItem Name="cbi1">Item1</ComboBoxItem>
    <ComboBoxItem Name="cbi2">Item2</ComboBoxItem>
    <ComboBoxItem Name="cbi3">Item3</ComboBoxItem>
</ComboBox>