1iveowl / Plugin.SegmentedControl

MIT License
170 stars 29 forks source link

Setting SelectedItem doesn't select SelectedSegment #105

Open tNRevan opened 4 years ago

tNRevan commented 4 years ago

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?

1iveowl commented 2 years ago

Feel free to create a PR