我下面的教程Binding a comboBox to an Enum 並想出了這個XML代碼:WPF默認ComboBox項時,數據綁定
<ComboBox
DisplayMemberPath="Key"
SelectedValuePath="Value"
ItemsSource="{Binding VolumeLevelList}"
SelectedValue="{Binding SelectedVolumeLevel, ValidatesOnDataErrors=True, Mode=TwoWay}"
Height="23" HorizontalAlignment="Left" Margin="189,70,0,0"
VerticalAlignment="Top" Width="120" />
我正在尋找一種方式來選擇一個默認的選擇,像
的SelectedIndex = 「0」
但那不是工作..
你是如何精確設置索引爲0?在代碼後面? – PoweredByOrange
@ programmer93不,只是作爲組合框中的一個屬性XML – drtf
請參閱下面的答案。 – PoweredByOrange