▶InvertBooleanConverter
True면 False, False면 True로 반대의 값으로 리턴되는 Converter
public class InvertBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool)
{
return !(bool)value;
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool)
{
return !(bool)value;
}
return value;
}
}
▶xaml에서 사용 예
<Button IsEnabled="{Binding IsBtnEnabled, Converter={StaticResource InvertBooleanConverter}}" />