【问题标题】:Xamarin.Forms ListView custom cell is not selectableXamarin.Forms ListView 自定义单元格不可选择
【发布时间】:2015-04-20 13:48:41
【问题描述】:

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

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"
                }
            }
        };
    }
}

如果我不添加任何子项,则单元格是可选择的。 如果我添加任何孩子,则无法再选择单元格。

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

【问题讨论】:

  • 尝试 - 将 'IsEnabled = false' 添加到标签和按钮 - 可能是它们正在捕获输入,因此单元格没有得到点击

标签: listview selection xamarin.forms


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-10
    • 2019-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-10
    相关资源
    最近更新 更多