c# - source binding not working windows phone 7 -
am showing list of movie panorama windows phone 7 app. on click on each movie showing movie details,cast. movie details , cast showing pivot control. movie details works fine when got show cast , doesnt work. have list of cast objects. , binding source listbox in cast pivot control , doesnt show data. please me. below classes have used. thank you
mainviewmodel.cs
public class mainviewmodel { public observablecollection<itemviewmodel> movieitems { get; set; } }
itemviewmodel.cs
public class itemviewmodel : inotifypropertychanged { private string _title; public string _title { { return _title; } set { if (value != _title) { _title = value; notifypropertychanged("title"); } } } private observablecollection<cast> _cast; public observablecollection<cast> _cast { { return _cast; } set { if (value != _cast) { _cast = value; notifypropertychanged("cast"); } } } .......... }
cast.cs
public class cast { public string name { get; set; } public string imagesource { get; set; } public cast(string _name, string _imagesource) { this.imagesource = _imagesource; this.name = _name; } } each movie have list of cast objects
moviemodel.cs
app.model.movieitems.add( new itemviewmodel() { _title = data["title"].tostring(), _cast=casobs, ........ } );
moviedetails.xaml
<listbox name="listbox" margin="0,0,-12,0" itemssource="{binding _cast}"> <listbox.itemtemplate> <datatemplate> <stackpanel margin="0,0,0,17" width="432" height="78"> <canvas> <textblock horizontalalignment="center" verticalalignment="bottom" margin="120,5,60,3" text="{binding name}" textwrapping="wrap" fontsize="32" style="{staticresource phonetextnormalstyle}"/> <image height="90" horizontalalignment="left" margin="12,10,0,0" name="image1" stretch="fill" verticalalignment="top" width="90" source="{binding imagesource}" /> </canvas> </stackpanel> </datatemplate> </listbox.itemtemplate> </listbox>
replace
notifypropertychanged("title");
to
notifypropertychanged("_title");
and
notifypropertychanged("cast");
to
notifypropertychanged("_cast");
hope it's help.