Вы можете использовать MultiDataTrigger вместо DataTrigger и использовать ComboBoxItemToStringConverter:
public class ComboBoxItemToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var combo = value as ComboBoxItem;
string content = combo?.Content.ToString();
return content;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Тогда Вы используете:
<Window.Resources>
...
<local:ComboBoxItemToStringConverter x:Key="ObjectToStringConverter" />
</Window.Resources>
<ComboBox.Style>
<Style TargetType="ComboBox">
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=CB1, Path=SelectedItem, Converter={StaticResource ComboBoxItemToStringConverter}}" Value="{StaticResource Str3}" />
</MultiDataTrigger.Conditions>
<Setter Property="Visibility" Value="Collapsed" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
Я надеюсь, что это работает для вас.
Редактировать: Если вы не хотите использовать код C #.Вместо использования «SelectedItem» используйте текст:
<Condition Binding="{Binding ElementName=CB1, Path=Text}" Value="{StaticResource Str3}" />
и удалите конвертер.