Plugin.SegmentedControl
Plugin.SegmentedControl copied to clipboard
Segmented control always selcted by default
Segmented control always selected by default. is there any ways i can deselect it be default ? if yes tell me the way.
There is currently no way. Are you trying to use this as a three state control?
Yes exactly.I need some 3 choice option control.User have to select 1 out of 3 from every option.
@1iveowl Do you have an opinion or a different idea? What if the selected index is less than 0 that would clear any selected segment or do you have a more clear way to do this?
@rjantz3 a negative number sounds could be solution, but it feels like a hack.
Alternatively introducing a new state with an enum of SelectedState/NotSelectedState. The later seems more clear. I think the default should be Selected, as this is how it works today, meaning that NotSelectedState must be specificed explicitely.
I agree that it feels like a hack for a primary setting mechanism but wouldn’t it be a side effect of any other way?
On May 25, 2019, at 8:16 AM, 1iveowl [email protected] wrote:
a negative number sounds could be solution, but it feels like a hack
Ok I did some hack and it is working fine. Just need to select some index which is not exist in the control. e.g:I have 3 option so I am choosing the index 3 which is not exist.
I know this is kinda old but negative index seems to be the way to go and @anirbandebroy kinda confirmed it works
If you are using MVVM, then the first - i.e. index zero - is selected because the default value of int is zero.
private int selectedIndex = -1; should work and have non selected