Shi*_*mmy 16 wpf xaml operators bitwise-operators
<Button IsEnabled="{Binding (Not IsDisabled)}" />
Run Code Online (Sandbox Code Playgroud)
有没有办法用纯xaml来做,或者我必须通过代码来做到这一点?PS.我问过这个问题我知道我可以像这样创建一个布尔转换器:
<ValueConversion(GetType(Boolean), GetType(Boolean))>
Public Class BooleanFlagSwitchConverter : Implements IValueConverter
Public Function Convert(value As Object, targetType As Type,
parameter As Object, culture As CultureInfo) As Object
Implements IValueConverter.Convert
Return Not value
End Function
Public Function ConvertBack(value As Object, targetType As Type,
parameter As Object, ByVal culture As CultureInfo) As Object
Implements IValueConverter.ConvertBack
Return Not value
End Function
End Class
[ValueConversion(typeof(bool), typeof(bool))]
public class BooleanFlagSwitchConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
CultureInfo culture)
{
return !(bool)value;
}
public object ConvertBack(object value, Type targetType, object parameter,
CultureInfo culture)
{
return !(bool)value;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8758 次 |
| 最近记录: |