I have a nullable Boolean property in my model.
I also have a custom property converter and custom segment control bound to the nullable Boolean.
In my ContentPage code file I have registered the custom data source provider and the segmented editor.
dataForm.PropertyDataSourceProvider = new NullableBoolPropertyDataSourceProvider();dataForm.RegisterEditor(nameof(Item.BoolToTest), EditorType.SegmentedEditor);Yet when I run the code and click the buttons in the segmented editor, it does not call the Boolean property setter.
Other properties in the model work fine in that their setter gets called when they are edited on the DataForm.
How do I get the buttons in the segmented editor to fire / call the Boolean setter?
Below is the code.
Public class TestModel{ [DisplayOptions(Header = "Yes / No / Unknown ?")] [Converter(typeof(NullableBoolPropertyConverter))] [DataSourceKey("NullableBoolSegementedControl")] public bool? BoolToTest { get { return this.boolToTest; } set { if (value != this.boolToTest) { this.boolToTest = value; OnPropertyChanged(); } } }}public class NullableBoolPropertyDataSourceProvider : PropertyDataSourceProvider{ public override IList GetSourceForKey(object key) { switch (key.ToString()) { case "NullableBoolSegementedControl": return new List<string> { "", "NO", "YES" }; default: return base.GetSourceForKey(key); } }}public class NullableBoolPropertyConverter : IPropertyConverter{ public object Convert(object value) { if (value is bool) switch ((bool?)value) { case true: return "YES"; case false: return "NO"; default: return ""; } if (value == null) return ""; return value; } public object ConvertBack(object value) { if (value is string) { switch ((string)value) { case "YES": return true as bool?; case "NO": return false as bool?; default: return null as bool?; } } switch ((bool?)value) { case true: return "YES"; case false: return "NO"; default: return ""; } }}