繁体   English   中英

如何在Xamarin Forms中的ImageCell上实现tap事件?

[英]How to implement tap event on ImageCell in Xamarin Forms?

我在TableView使用ImageCell来创建各种设置页面。

<TableView Intent="Settings" HasUnevenRows="true">
    <TableRoot>
        <TableSection>
            <ImageCell x:Name="darkTheme" Text="Dark theme" />
            <ImageCell x:Name="lightTheme" Text="Light theme" />
        </TableSection>
    </TableRoot>
</TableView>

在我的C#代码中,我有以下内容:

lightTheme.Tapped += new EventHandler((e, s) =>
{
    Debug.WriteLine("Light theme tapped");
});

每次点击图像单元格时都不会触发它。 任何人都知道如何在ImageCell正确实现点击事件,就像TapGestureRecognizer中的ViewCell

从广泛的评论和聊天中收集到,我看到你有一个适用于TableView的自定义渲染器。 iOS上的此渲染器将属性AllowSelection设置为false,从而有效地阻止您选择单元格,从而导致触发事件不被触发。

我只是想把它作为未来参考的解决方案。

暂无
暂无

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

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