【问题标题】:Unable to tap same listview item twice xamarin无法两次点击相同的列表视图项目xamarin
【发布时间】:2019-01-21 11:58:30
【问题描述】:

在使用 SelectedItem 属性的 xamarin 列表视图中,我无法访问相同的列表视图项两次。 1.点击列表中的一个项目。它导航到另一个后面。 2.返回上一页并在列表中点击它正在导航到其他页面的相同项目。

  <ListView
            ItemsSource="{Binding UIUnionListWrapper}"
            **SelectedItem="{Binding DeviceSession, Mode=TwoWay}">**
  internal DeviceSession _deviceSession;

    public DeviceSession DeviceSession
    {
        get { return _deviceSession; }
        set
        {
            SetProperty(ref _deviceSession, value);
            HandleItemSelectedAsync(); //navigating to other page
        }
    }

【问题讨论】:

  • 当您导航回上一个列表所在的页面时,您必须将所有 isSelected 项目的属性设置为 false。否则 listview 保留该选择(因为对象尚未被释放)。
  • 我会知道根本原因。请您分享代码 sn-p 来执行此操作,或者您能否提供有关 isSelected 属性的更多详细信息。
  • 有人请提供解决方案
  • 在您的 HandleItemSelectedAsync 设置 DeviceSession = null 后导航
  • 当您设置 DeviSession=null 时,我已经尝试过您的解决方案,它正在导航多次。因为将值重新分配为 null。

标签: xamarin


【解决方案1】:

此代码按预期工作:if (SelectedItem != null){await PushModelPage(newSessionListPage(SelectedItem, Navigation));SelectedItem = null;}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-11
    • 2018-07-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多