wpf combobox display 1st item from list
i have a combobox bou开发者_JAVA技巧nd to an ObservableCollection:-
<ComboBox Name="combo" ItemsSource="{Binding Things}" SelectionChanged="ComboBox_SelectionChanged" >
in the code behind I have
Dim thingArray = New ObservableCollection(Of Things)
Me.combo.DataContext = Me.thingArray
Assume thingArray is initialized to 5 Thing
objects and Thing
has a toString()
implementation. I want to display the first item Thing(0)
by default on the ComboBox. How do i do that?
If Me.thingArray.Count > 0 Then Me.combo.SelectedIndex = 0
精彩评论