Hello,
Welcome to Microsoft Q&A!
Based on the code you provided, here is some basic information you need to know. The CbTipocombustibles.Name
is just the name of the ComboBox, it is not the value that users selected. You need to get the value from the TextBlock inside the ComboBoxItem. Then you could check that value to decide if you need to hide the TextBox or TextBlock.
Please try the following code:
ComboBox CbTipocombustibles = (ComboBox)sender;
//get selected comboboxitem
ComboBoxItem item = (ComboBoxItem)CbTipocombustibles.SelectedItem;
//get textblock inside the comboboxitem
TextBlock textblock = (TextBlock)item.Content;
//get the value which is selected
if (textblock.Text == "textgasolina")
{
txttanqueel.Visibility = Visibility.Collapsed;
}
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.