你的装订没什么问题。这对我来说很好;
<Window.Resources>
<local:ControlTagVisibilityConverter x:Key="ControlTagVisibilityConverter" />
</Window.Resources>
<RadioButton
Tag="7"
Visibility="{Binding Path=Tag,
Converter={StaticResource ControlTagVisibilityConverter},
RelativeSource={RelativeSource Mode=Self}}"/>
ControlTagVisibilityConverter.cs
public class ControlTagVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var valueAsString = (string) value;
var valueAsInt = int.Parse(valueAsString);
switch (valueAsInt)
{
case 7:
return Visibility.Visible;
default:
return Visibility.Hidden;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}