c# - Reload LongListSelector with updated data from local database - Windows Phone 8 -


i having issue longlistselector on windows phone 8 application. after selecting , editing record longlistselector , submitting changes local database, longlistselector doesn't show updated name,unless close , reopen application. data being updated, not showing. there way have list select while app still open? xaml list:

 <!--contentpanel - place additional content here-->     <grid x:name="contentpanel" grid.row="1" margin="12,0,12,0">         <phone:longlistselector x:name="llsmodules"                                margin="0,0,-12,0"                                itemssource="{binding modules}"                                selectionchanged="llsmodules_selectionchanged">             <phone:longlistselector.itemtemplate>                 <datatemplate>                     <stackpanel margin="0,0,0,17">                         <stackpanel orientation="horizontal">                             <grid horizontalalignment="stretch" width="420"  >                                                          <grid.columndefinitions>                                 <columndefinition width="*" />                                     <columndefinition width="100"/>                                     <columndefinition width="100"/>                                 </grid.columndefinitions>                             <textblock text="{binding name,stringformat='name: {0}'}"                                 textwrapping="wrap"                                 maxwidth="300"                                 style="{staticresource phonetextlargestyle}"                                        horizontalalignment="left"                                        grid.row="1"                                        />                             </grid>                         </stackpanel> 

and code behind.

public modulepage()     {         initializecomponent();                   datacontext = app.viewmodel;     }      protected override void onnavigatedto(navigationeventargs e)     {         app.viewmodel.loadmodulesdata();         llsmodules.itemssource = app.viewmodel.module;                 }      private void llsmodules_selectionchanged(object sender, selectionchangedeventargs e)     {         if (llsmodules.selecteditem == null)             return;          navigationservice.navigate(new uri("/moduledetails.xaml?moduleid=" + (llsmodules.selecteditem modules).id, urikind.relative));      } 

and data model

 [table(name = "modules")]     public class modules : inotifypropertychanged, inotifypropertychanging     {         public modules()         {         }          private int _id;         [column(isprimarykey = true, isdbgenerated = true, dbtype = "int not null identity", canbenull = false, autosync = autosync.oninsert)]         public int id         {                         {                 return _id;             }             set             {                 if (_id != value)                 {                     notifypropertychanging("id");                     _id = value;                     notifypropertychanged("id");                 }             }         }          private string _name;         [column(dbtype = "nvarchar(255)", canbenull = false)]         public string name         {                         {                 return _name;             }             set             {                 if (value == "")                     throw new exception("module name required field");                  if (_name != value)                 {                     notifypropertychanging("name");                     _name = value;                     notifypropertychanged("name");                 }             }         } 

thanks much!

in xaml change binding used display name twoway.

text="{binding name, mode=twoway, stringformat='name: {0}'}" 

this lets xaml know monitor inotifypropertychanges of name property.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -