<Button IsEnabled="{Binding (Not IsDisabled)}" />
有沒有辦法用純XAML做到這一點,否則我將不得不通過代碼來做到這一點? PS。我問的問題,知道我可以創建一個布爾值轉換器是這樣的:XAML'NOT'運算符?
<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;
}
}
我認爲這是優選的<按鈕的IsEnabled = 「{結合的IsEnabled}」/>在肯定的。 :) – user347594 2010-06-21 03:54:52