开发者

WPF - binding integer list to combobox

开发者 https://www.devze.com 2023-01-18 13:49 出处:网络
I want to bind开发者_StackOverflow a List to a WPF combobox in xaml. Wondering what is the simplest way to do it.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消