繁体   English   中英

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

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

有没有办法识别 CheckBox 控件上的 Tapped 事件? CheckedChanged 事件也会在创建容器(在我的情况下为 CollectionView)和滚动时触发,相反,我只需要在用户点击时管理 state 的更改。 有什么技巧吗?

使用 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>

祝你好运

暂无
暂无

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

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