I have two ToggleButtons
.
I need to bind one IsChecked
property to the other ToggleButton
.
I use a custom Converter
to inverse the value.
However, it's not working? Here's my code:
XAML:
<ToggleButton
IsChecked="{Binding Path=ToggleButton.IsChecked, ElementName=menuCatUit,
Converter={StaticResource InvertBool}}"/>
<ToggleButton x:Name="menuCatUit" IsChecked="True" />
Code:
[ValueConversion(typeof(bool), typeof(bool))]
public class InverseBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType != typeof(bool))
throw new InvalidOperationException("The target must be a boolean");
return !(bool)value;
}
}
RadioButton
any difference? I just need the binding to work :D – DeMama