我:的SelectedItem中的ObservableCollection
<DataTemplate x:Name="_ComboBoxTemplate" x:Key="_ComboBoxTemplate">
<StackPanel Orientation="Horizontal">
<StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock VerticalAlignment="Center" Text="{Binding}" FontSize="24"/>
</StackPanel>
</StackPanel>
</StackPanel>
</DataTemplate>
<ComboBox x:Name="_criteria" ItemTemplate="{StaticResource _ComboBoxTemplate}" ItemsSource="{Binding}"/>
在後面的代碼:
this.DataContext = new string[] { "0", "1", "2", "3", "4", "5" };
我如何得到它,以便在ComboBox
默認SelectedItem
是5
?
你有一個虛擬機綁定到視圖嗎? – DHN