У меня есть две кнопки привязки в моем приложенииWPF кнопку
Теперь я хочу, чтобы связать btnOff с! Ison. Значение является btnOn активизирован, btnOff должен быть отключен, и наоборот
EDIT: Ниже моя реализация:
<Button x:Name="btnOn" Content="On" Width="45" Height="24" IsEnabled="{Binding isOn, Converter={StaticResource BoolInverter}}" />
<Button x:Name="btnOff" Content="Off" Width="45" Height="24" IsEnabled="{Binding isOn} />
public class BoolInverterConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is bool)
{
return !(bool)value;
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is bool)
{
return !(bool)value;
}
return value;
}
}
Что у вас есть? –
Я реализовал Конвертер для инвертирования логического значения, и теперь он отлично работает. – xaria