Two way binding not working on read-only properties?
Posted: 10 May 2023, 04:37
Hello guys
Like to get an understanding of why this happens here:
Im working in C# in Unity, I have this control in XAML file
<CheckBox Content="BooleanBinding Test" x:Name="TestCheckbox" IsChecked="{Binding AutoBoolValue, Mode=TwoWay}"/>
The data context of TestCheckbox is set to this class BindingContainer_Bool
Where the IsChecked property is binding to the class's AutoBoolValue property
Where the getter and setter are point to a bool member variable inherited from parent class
Code of this class can be seen below
It is throwing an error in Unity
"[NOESIS/E] A TwoWay or OneWayToSource Binding cannot work on a read-only property"
I checked the NoesisGUI documentation, the CheckBox's IsChecked property is not read only
Anyone has idea on this?
Like to get an understanding of why this happens here:
Im working in C# in Unity, I have this control in XAML file
<CheckBox Content="BooleanBinding Test" x:Name="TestCheckbox" IsChecked="{Binding AutoBoolValue, Mode=TwoWay}"/>
The data context of TestCheckbox is set to this class BindingContainer_Bool
Where the IsChecked property is binding to the class's AutoBoolValue property
Where the getter and setter are point to a bool member variable inherited from parent class
Code of this class can be seen below
Code: Select all
public class BindingContainer_Bool: DataContainer_Bool,INotifyPropertyChanged
{
public bool AutoBoolValue => Value;
protected override void OnValueChanged(bool newValue)
{
base.OnValueChanged(newValue);
OnPropertyChanged(nameof(AutoBoolValue));
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
It is throwing an error in Unity
"[NOESIS/E] A TwoWay or OneWayToSource Binding cannot work on a read-only property"
I checked the NoesisGUI documentation, the CheckBox's IsChecked property is not read only
Anyone has idea on this?