Xamarin.Forms ListView 自定义单元格不可选择

Xamarin.Forms ListView custom cell is not selectable

我创建了一个自定义单元格:

public class TextCell2 : ViewCell
{
    public TextCell2()
    {
        View = new StackLayout
        {
            Orientation = StackOrientation.Horizontal,
            HorizontalOptions = LayoutOptions.FillAndExpand,
            Children =
            {
                new Label
                {
                    Text = "Test"
                },
                new Button
                {
                    Text = "Test 2"
                }
            }
        };
    }
}

如果我不添加任何 child,该单元格 select 可用。 如果我添加任何 child,单元格将不再是 select。

请帮助我如何在自定义视图中使用 selection。

为您的标签和按钮设置 InputTransparent=true。

他们目前正在捕捉点击。 InputTransparent 会让点击通过父元素。