yurkinh / Plugin.Maui.SegmentedControl

.NET MAUI Port of XF Segmented control
MIT License
12 stars 6 forks source link

Setting SelectedSegment to -1 to clear selected segment causes null reference in Android #4

Closed TrueMoniker closed 7 months ago

TrueMoniker commented 7 months ago

Setting SelectedSegment to -1 to clear selected segment causes null reference in Android. I'd expect the -1 to have no segment selected. If -1 is not supported, how do I deselect a value in the Segmented Control?

Reproducable Example Open a view on Android with the SegmentedControl below:

<segmented:SegmentedControl SelectedSegment="-1">
    <segmented:SegmentedControl.Children>
        <segmented:SegmentedControlOption Text="yes" />
        <segmented:SegmentedControlOption Text="no" />
    </segmented:SegmentedControl.Children>
</segmented:SegmentedControl>

Error Message System.NullReferenceException: Object reference not set to an instance of an object. at at Plugin.Maui.SegmentedControl.Handlers.SegmentedControlHandler.MapSelectedTextColor(SegmentedControlHandler handler, SegmentedControl control)

yurkinh commented 7 months ago

Hello @TrueMoniker Thanks for reporting an issue. I will take a look at it.

yurkinh commented 7 months ago

Hello @TrueMoniker Check please the latest v1.0.8 from nuggets - it contains a fix for this issue from pull #5

TrueMoniker commented 7 months ago

Hello @yurkinh @MykhailoDav v1.0.8 fixed it. Thank you so much! Very Excellent