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.

enter image description here

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

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -