I have a list of countries in a listview grouped by region (Europe, Americas, Asia Pacific etc...). There is another switch on each region that allows me to select/deselect all countries in a region. There's a binding on the region level switch which runs code the code in the view model. This works well.
I've also got some code in the viewmodel which runs every time a country level switch is selected. The purpose for this is to check if all countries are selected, and one country is deselect, unselect the region level switch.
The impact of this is that this causes the region level selection to fire unexpectedly.
So, in this image, if I deselect Algeria, the Middle East & Africa switch is turned off (which is expected). This then fires the binding call back on the Selected property for that switch, which causes all the countries to the deselected.
The question is, is there is way in code to temporarily stop the binding calling back of switch? The xaml example of each switch in the listview is:
The solution is build with Xamarin Forms PCL.