How to poulate a combobox in wpf applikation

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
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
 
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
 
Back
Top