繁体   English   中英

如何从列表中选择特定的班级项目?

[英]How to select specific class item from list?

如何从列表中选择特定的班级项目? 我只想在标签中绑定名称。

mycountry.cs

public class mycountry{

private string Id;
private string name;
private string capital;
private string majorcity;


public string ID { get{return Id;} set{Id = value;}}
public string Name { get{return name;} set{name = value;}}
public string Capital { get{return capital;} set{capital = value;}}
public string Majorcity { get{return majorcity;} set{majorcity = value;}}
}

mycountrypage.xaml.cs

List<mycountry> c;
c =  DB.GetCountry(); 

ListView list = new ListView{
ItemsSource = c,
ItemTemplate = new DataTemplate(() =>{ 
Label name = new Label(); name.SetBinding(Label.TextProperty, c.?)}
}

将现有的TextCell类型用于简单单元格

list.ItemTemplate = new DataTemplate(typeof(TextCell));
list.ItemTemplate.SetBinding(TextCell.TextProperty, "Name");

暂无
暂无

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

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