How to poulate a combobox in wpf applikation

T

Tony Johansson

Hello!

In win form I could populate my combobox from an enum by using this
statement
cboHousing.Items.AddRange(Enum.GetNames(typeof(HousingType)));
but it seems that this is not possible in WPF because the combobox does not
have an AddRange method.

Is the only way to loop through and add each item to the combobox.

//Tony
 
T

Tony Johansson

Peter Duniho said:
You should be able to set the ItemsSource property to the return value of
the GetNames() method. Does that not work for you?

Pete

Yes I missed this and it's less code to write then in win forms.
cboAirLine.ItemsSource = Enum.GetNames(typeof(carType));

//Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top