c# - I have some issue with ObservableCollection, in my list there are values added but they are not showing in my list view -
this code have written far, observablecollection list populated string values list view won't show text. there aim missing or doing wrong? happy if give me reply on this!
public class interactivelistviewcode : contentpage { public static observablecollection<string> items { get; set; } public interactivelistviewcode() { items = new observablecollection<string>() { }; //list<string> items = new list<string>(); listview lstview = new listview(); lstview.ispulltorefreshenabled = true; //lstview.refreshing += onrefresh; lstview.itemselected += onselection; lstview.itemtapped += ontap; lstview.itemssource = items; var temp = new datatemplate(typeof(textviewcell)); lstview.itemtemplate = temp; content = lstview; } internal void insertcomanyname(string[] companyname, string[] idforcompany) { (int = 0; < companyname.length; i++) { string temp; temp = companyname[i]; items.add(temp); debug.writeline("this in items list " + items[i]); } }
and "textviewcell" class:
public class textviewcell : viewcell { public textviewcell() { stacklayout layout = new stacklayout(); layout.padding = new thickness(15, 0); label label = new label();
label.setbinding(label.textproperty, "."); layout.children.add(label); var moreaction = new menuitem { text = "more" }; moreaction.setbinding(menuitem.commandparameterproperty, new binding(".")); moreaction.clicked += onmore; var deleteaction = new menuitem { text = "delete", isdestructive = true }; // red background deleteaction.setbinding(menuitem.commandparameterproperty, new binding(".")); deleteaction.clicked += ondelete; this.contextactions.add(moreaction); this.contextactions.add(deleteaction); view = layout; }
Comments
Post a Comment