简体   繁体   中英

Xamarin.Forms: Tapped event on CheckBox control

Is there a way to recognize something like Tapped event on the CheckBox control? CheckedChanged event is also triggered at the creation of the container (in my case a CollectionView) and at the scroll too, instead I need to manage the change of state only at the user's tap. Any tricks?

Make the input of your checkbox transparent using InputTransparent and Wrap it in a Stack or some other layout and get the events from your Layout

<StackLayout>  <!--This will now take your checkbox click events and you can wrap it under other layouts-->
    <StackLayout.GestureRecognizers>    
          <TapGestureRecognizer
            Command="{Binding CheckboxTappedCommand}"
            />
    </StackLayout.GestureRecognizers>    
  <CheckBox InputTransparent= "True" IsChecked="{Binding IsChecked}" />
</StackLayout>

Goodluck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM