【问题标题】:How to show items in Zebble ItemPicker?如何在 Zebble ItemPicker 中显示项目?
【发布时间】:2017-04-12 21:30:55
【问题描述】:

我将formfield的control.datasource设置为一个对象,然后 在后面的代码中填写它,但是当我在运行时点击它时它只会显示 我设置的值的对象的类名。

我想我已经遵循了这里的文档: Zebble ItemPicker-Class

我的代码是:

 mypage.zbl

<FormField z-of="ItemPicker" Id="Type" LabelText="Type" 
  Control.AllowNull="true"
  Control.DataSource="@(Database.GetList&lt;ContactType&gt;())" />

myentity

public partial class Contact : GuidEntity
{
   public string Name { get; set; }

}

here is a screen shot of my application

【问题讨论】:

    标签: xamarin-zebble zebble


    【解决方案1】:

    当您将 ItemPicker 的数据源设置为某个 对象列表 时,将为每个项目显示该对象的 ToString()

    解决问题的最简单方法是在源类中添加 ToString() 方法:

    public partial class Contact : GuidEntity
    {
       public string Name { get; set; }
    
       public override string ToString() => this.Name;
    }
    

    【讨论】:

      猜你喜欢
      • 2021-05-17
      • 2013-09-22
      • 2011-04-27
      • 1970-01-01
      • 1970-01-01
      • 2014-02-27
      • 2021-03-15
      • 2013-03-26
      • 2019-11-19
      相关资源
      最近更新 更多