How to Update ObservableCollection on click in c# with or without using LINQ in Windows 10 universal app development -


hello new windows app development , trying update observablecollection in c# reflect changes dynamically in xaml ui .but changes not reflect in ui.am doing wrong or doesn't work windows 10 or what.

someone please correct me or suggest me best approach doing.

thanks in advance.

my class:

public class students {       public string name;       public int age;       public int section_no;   } 

my c# code:

    public observablecollection<students> student = new observablecollection<students>();         private void filteritem_click(object sender, routedeventargs e)     {         menuflyoutitem selecteditem = sender menuflyoutitem;          if (selecteditem != null)         {             if (selecteditem.tag.tostring() == "section")             {                 student =new observablecollection<students>(student.orderby(i => i.section_no));              }             else if (selecteditem.tag.tostring() == "age")             {                 student = new observablecollection<students>(student.orderby(i => i.age));             }             else if (selecteditem.tag.tostring() == "name")             {                 student = new observablecollection<students>(student.orderby(i => i.name));             }         }     } 

your student variable must property in order ui bind correctly. not that, must implement inotifypropertychanged, creating new instances of collection in method.

private observablecollection<student> _students;  public observablecollection<student> students {     { return _students; }     set     {         _students = value;          //notify property changed stuff.         onpropertychanged();     } } 

don't forget implement inotifypropertychanged containing class.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -