WPF - binding integer list to combobox
I want to bind开发者_StackOverflow a List to a WPF combobox in xaml. Wondering what is the simplest way to do it.
(The reason behind is I want to maintain the years as integer rather than doing the type conversion from string to int. I get a list of years(2009,2010,2011) from the DB and want to be able to bind this to the combo and get the selected value also in int.)
Thanks, Mani
Simply bind the combo to an ObservableCollection<int>
if you want 2 way db or List<int>
for one way and retrieve the selected year by using SelectedItem
精彩评论