Plugin.SegmentedControl icon indicating copy to clipboard operation
Plugin.SegmentedControl copied to clipboard

Setting SelectedItem doesn't select SelectedSegment

Open tNRevan opened this issue 5 years ago • 1 comments

When setting the SelectedItem property of SegmentedControl the correct SelectedSegment with (SegmentedControlOption.)Item equal to SelectedItem is not selected.

Now it really hurts databinding scenario. In my case, I have 3 SegmentedControlOption with Items set to (null), true and false. Text is set to their respective translation in app language. When I databind SelectedItem to either value, nothing changes now - the first SegmentedControlOption is selected regardless of the value.

First of all, selecting SelectedSegment through SelectedItem works only if TextPropertyName is defined. And even if it is defined, it uses equality operator ==, which is really debatable, because usually you want object equality, not reference equality. See SegmentedControl. OnSelectedItemChanged.

I could implement a change, but it would mean slight backward incompatibility, as before SelectedSegment wasn't set when TextPropertyName wasn't defined. But I would consider this more like a bugfix, as it doesn't really make sense to differ between those cases. What do you think about it?

tNRevan avatar Nov 19 '20 20:11 tNRevan

Feel free to create a PR

1iveowl avatar Jan 08 '22 13:01 1iveowl