I have a radiobutton group which I binding to a boolean value but it isn't being picked up in the XAML - am sure it's something simple I am missing - any pointers appreciated.
passed
is set to false.
XAML
<RadioButton Width="64"
IsChecked="{Binding passed, Converter={StaticResource BoolInverterConverter}}"
GroupName="Result">Yes</RadioButton>
<RadioButton Width="64"
IsChecked="{Binding passed, Converter={StaticResource BoolInverterConverter}}"
GroupName="Result">No</RadioButton>
BoolInverterConverter
:
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;
}
}
Not populated:
ViewModel:-
public ResultsViewModel()
{
private Results_results = new Results();
public ResultsViewModel()
{
_results.Passed= false;
}
}
Result class:-
public class Results
{
private bool passed;
public bool Passed{ get => passed; set => passed= value; }
}