Xamarin Forms binding collection of strings c# -
i have bind collection of string listiview contains elements these strings, don't know how this:
name.setbinding(label.textproperty, ??? );
i know in xaml can this
<label text="{binding }"/>
but what's equivalent in codebehind? need customcell because listitem has other elements
viewmodel:
private bindablecollection<string> _wifinetworks; public bindablecollection<string> wifinetworks { { return _wifinetworks; } set { if (value != _wifinetworks) { _wifinetworks = value; notifyofpropertychange(() => wifinetworks); } } }
in view:
var wifilist = new listview { rowheight = 50 }; wifilist.setbinding(listview.itemssourceproperty, new binding("wifinetworks")); wifilist.itemtemplate = new datatemplate(typeof(customcell));
customcell.cs:
public customcell() { var name = new label { textcolor= (color)application.current.resources["foregroundcolor"], fontsize = 17 }; name.setbinding(label.textproperty, ??? ); }
the "." binding path bind property directly bindingcontext
name.setbinding(label.textproperty, "." );
Comments
Post a Comment