c# - Windows 10 Development: How to refresh ListView whenever there is a change in the items inside ListView? -


i new concept of data binding , don't think understood completely. have class named project linkedlist of type todo 1 of properties. when navigate 1 instance of project, display linkedlist of type todo in listview. have created functions allow me change sequences of nodes in linkedlist (move up, move down) , remove selected node (delete). want listview refresh whenever there change in linkedlist, (move up, move down or delete). however, cannot achieve that. here code: (not parts included)

xaml of page:

<listview x:name="mylistview" itemssource="{binding source={staticresource todos}, mode=twoway}">         <listview.itemtemplate>         <datatemplate>             <stackpanel>                 <checkbox x:name="mycheckbox"                            content="{binding todotitle, mode=twoway}"                            ischecked="{binding iscompleted, mode=twoway}">                                      </stackpanel>         </datatemplate>     </listview.itemtemplate>       </listview> 

c# datamodel:

public class todo : inotifypropertychanged {     private string todotitle;     private bool iscompleted;     public event propertychangedeventhandler propertychanged = delegate { };     public string todotitle { { return this.todotitle; } set { this.todotitle = value; this.onpropertychanged(); } }     public bool iscompleted { { return this.iscompleted; } set { this.iscompleted = value; this.onpropertychanged(); } }      public void onpropertychanged([callermembername] string propertyname = null)     {         // raise propertychanged event, passing name of property value has changed.         this.propertychanged(this, new propertychangedeventargs(propertyname));     }  }  public class projects : inotifypropertychanged {     private linkedlist<todo> todos;      public event propertychangedeventhandler propertychanged = delegate { };      public linkedlist<todo> todos { { return this.todos; } set { this.todos = value; this.oncollectionchanged(); } }      public projects()     {         todos = new linkedlist<todo>();      }     public void onpropertychanged([callermembername] string propertyname = null)     {         // raise propertychanged event, passing name of property value has changed.         this.propertychanged(this, new propertychangedeventargs(propertyname));     } } 

thank you.

first advise read mvvm, , try follow basic tutorials this one.

you can use mvvm light avoid managing inotifypropertychanged @ first (but it's know how mvvm light work under hood).

to come problem, current code notifies if set full todos list. if want aware of change in list (seing when item add/remove/update), looking observablecollection, not linkedlist.

hope helps.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -