how to make a Textblock through a combobox not visible

Javier R 211 Reputation points
2020-10-02T19:50:06.023+00:00

Hello:

how to make a Textblock not visible through a combobox using one of the options?

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. Roy Li - MSFT 31,481 Reputation points Microsoft Vendor
    2020-10-07T05:43:37.507+00:00

    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.

    0 comments No comments