I am using Xamarin forms switch inside collection view like the below.
<CollectionView ItemsSource="{Binding SwitchStatus}">
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout>
<StackLayout HeightRequest="100" Orientation="Horizontal" HorizontalOptions="CenterAndExpand" Spacing="30">
<Switch x:Name="mySwitch" IsToggled="{Binding State}">
<Switch.Behaviors>
<prism:EventToCommandBehavior EventName="Toggled" CommandParameter="{Binding .}" Command="{Binding BindingContext.UpdateCommand,Source={x:Reference myPage}}"/>
</Switch.Behaviors>
</Switch>
</StackLayout>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Toggled event of the Switch getting fired automatically whenever I navigate to that page because of IsToggled Binding property set. Is there any way to restrict Switch Toggled event when the user not manually triggered?
To be more clear, I have attached my sample here.
Followed prism MVVM, EventToCommandBehavior I should follow all these.
Help me with the sample code would be greatful.