从 Combobox 获取 ComboBoxItem

Get ComboBoxItem from Combobox

在我的通用 windows 应用程序中,我有以下 "xaml" :

<ComboBox Margin="8" Header="Language" x:Name="cmbLanguage" x:Uid="cmbLanguage" ItemsSource="{x:Bind Languages}" SelectionChanged="LanguageComboBox_SelectionChanged"/>

现在我需要遍历我的组合框并获取组合框项目以禁用其中的一些。我怎样才能从隐藏的代码中访问这些项目?

Now i need to iterate through my combobox and get the combobox items to disable some of them. How can i get access to the items from code behind?

可以通过ContainerFromIndex方法获取ComboBoxItem,设置IsEnabled 属性为false或true,更多内容可参考下文

ComboBoxItem^ item =  dynamic_cast<ComboBoxItem^>(cmbLanguage->ContainerFromIndex(CurrenIndex));
item->IsEnabled = false;