Hello,
Welcome to Microsoft Q&A!
A simple way to do that is to remove the ComboBox.ItemsSource property of other ComboBox controls when you select Gasoline in the ComboBox.
Like this:
private void FontsCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
FontFamily fontFamily = (FontFamily)FontsCombo.SelectedItem;
if (fontFamily.Source.Equals("Courier New"))
{
//if the key value is selected, remove the items source of other controls.
FontsCombo1.ItemsSource = null;
}
else
{
// if the selected item is not the key value, check if the other combobox's ItemsSource have value. If not, add the source.
if (FontsCombo1.ItemsSource == null)
{
FontsCombo1.ItemsSource = fonts;
}
}
}
Check if the selected item is the target item. If it is, then remove other combobox's item source.
If the selected item is not the target item, then check other combobox's item source. If the item source is null, add the item source back.
Thank you.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.