简体   繁体   English

Xamarin.Forms:复选框控件上的点击事件

[英]Xamarin.Forms: Tapped event on CheckBox control

Is there a way to recognize something like Tapped event on the CheckBox control?有没有办法识别 CheckBox 控件上的 Tapped 事件? 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. CheckedChanged 事件也会在创建容器(在我的情况下为 CollectionView)和滚动时触发,相反,我只需要在用户点击时管理 state 的更改。 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使用 InputTransparent 使复选框的输入透明并将其包装在 Stack 或其他布局中,并从您的布局中获取事件

<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祝你好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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