buttons are lost after redirection of the page using ObservableCollection in windows phone 8 c# -


in windows phone application creating dynamic buttons using observablecollection btn_groupname_click event below:

using system; using system.collections.generic; using system.linq; using system.net; using system.windows; using system.windows.controls; using system.windows.navigation; using microsoft.phone.controls; using microsoft.phone.shell; using microsoft.phone.userdata; using system.windows.media; using microsoft.phone.maps.controls; using system.collections.objectmodel; using system.collections;  namespace getcontacts {     public partial class creategroups : phoneapplicationpage     {         string buttonname = "";         public observablecollection<group> groupbtn;         list<customcontact> contact = new list<customcontact>();         list<customcontact> listofcontact2 = new list<customcontact>();         //list<group> buttons = new list<group>();          list<button> buttons = new list<button>();         list<list<customcontact>> lls = new list<list<customcontact>>();         public creategroups()         {             initializecomponent();             groupbtn = new observablecollection<group>();         }          private void btn_groupname_click(object sender, routedeventargs e)         {             if (tb_groupname.text != string.empty)             {                 groupbtn.add(new group { name = tb_groupname.text });                 buttonname = tb_groupname.text;                 lb_groupofcontacts.datacontext = groupbtn;                 tb_groupname.text = string.empty;             }         }           } } 

and below group class:

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.net; using system.windows; using system.windows.controls; using system.windows.navigation; using microsoft.phone.controls; using microsoft.phone.shell; using getcontacts.resources; using microsoft.phone.userdata;  namespace getcontacts {     public class group     {         public string name { get; set; }         public group()         {           }         public group(button btn)         {             name = btn.name;          }     } } 

its working fine , create multiple buttons when working on current page when go next page , after come previous page buttons lost, how can these buttons after redirection of page. kindly suggest me. waiting reply. thanks.

if want maintain state of collection through out app can take collection static data member,

        public creategroups()         {             initializecomponent();             if(groupbtn!== null)             groupbtn = new observablecollection<group>();         } public static observablecollection<group> groupbtn; 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -