c# - Listview on Windows Phone: Items not listing correctly -
my requirement implement list of countries user select , phone number. in desperate attempts, this article followed. have listview setup way:
the country names trial, not make sense.
viewmodel: i've hard-coded list of countries
//contructor class public countrylist_test() { //creating static data memberrs (hardcoded logic) var list_countrylist = new list { new countrylist_countrynames{countryname = "ffsdfndf"}, new countrylist_countrynames{countryname = "hfhjf"}, new countrylist_countrynames{countryname = "vcxbv"}, new countrylist_countrynames{countryname = "ujhfg"}, new countrylist_countrynames{countryname = "vbcvb"}, new countrylist_countrynames{countryname = "fdfgd"}, new countrylist_countrynames{countryname = "dfdhgfjjyhg"}, new countrylist_countrynames{countryname = "khjkj"}, new countrylist_countrynames{countryname = "fffg"}, }; //grouping country names var countriesbycategories = list_countrylist.groupby(x => x.countryname).select(x => new countrylist_groupmechanism { countrynameforgroupmechanism = x.key,countrylistforgroupmechanism = x.tolist() }); countrylistforgroupmechanism = countriesbycategories.tolist(); } public class countrylist_countrynames { public string countryname { get; set; } //public int internationalcode { get; set; } } public class countrylist_groupmechanism { public string countrynameforgroupmechanism { get; set; } public list countrylistforgroupmechanism { get; set; } } }
this looks fine. model: in constructor of class bpage2 <pre> public bpage2() { //creating instance of view model , setting data context of page this.initializecomponent(); var viewmodel = new countrylist_test(); this.datacontext = viewmodel; }
this view: <!--countrylistforgroupmechanism comes viewmodel--> <listview name="lstv_countries" itemssource="{binding countrylistforgroupmechanism}" > </listview>
and output, , driving me nuts. sure issue in v-m level, don't know where.
please me figure out issue is. in advance :)
if expect see country names set displaymemeberpath, following should do:
<listview name="lstv_countries" displaymemeberpath="countrynameforgroupmechanism" itemssource="{binding countrylistforgroupmechanism}" > </listview>
or use itemtemplate
<listview name="lstv_countries" itemssource="{binding countrylistforgroupmechanism}" > <listview.itemtemplate> <datatemplate> <textblock text="{binding path=countrynameforgroupmechanism}"/> </datatemplate> </listview.itemtemplate> </listview>
Comments
Post a Comment