c# - Listview not appearing right away xamarin forms -


the third or page in app contains listview, list reason doesn't display until either toggle view (which switches views itemsource list) or rotate screen.

if toggle twice (so original starting state) listview there still. seems bug haven't been able find on it.

public partial class reviewrequestspage : contentpage {     private readonly list<requestcell> closedrequestcells = new list<requestcell>();     private readonly list<requestcell> openrequestcells = new list<requestcell>();      public reviewrequestspage()     {         initializecomponent();         navigationpage.sethasnavigationbar(this, false);         bindingcontext = new svgimagesviewmodels();         new footer().setgesturerecognizers(null, notifications, help, home, this);         loadrequestlists();         toggleswitch.propertychanged += (o, ea) => { handletoggle(((switch) o).istoggled); };     }      ....      private void loadrequestlists()     {         userdialogs.instance.showloading("loading requests...", masktype.black);         var client = new restservice().client;         var request =             new requestservice().getallrequests();         client.executeasync(request, response =>         {             var mylist = jsonconvert.deserializeobject<list<request>>(response.content, new datetimeconverter());             mylist.foreach(r =>             {                 if (r.status.type == statustype.closed) closedrequestcells.add(new requestcell(r));                 else if (r.status.type != statustype.deleted) openrequestcells.add(new requestcell(r));             });             userdialogs.instance.hideloading();             requestslist.itemsource = openrequestcells;          });     }     private void handletoggle(bool istoggled)     {         switchlabel.text = istoggled ? constants.closed : constants.open;         requestslist.itemssource = istoggled ? closedrequestcells : openrequestcells;     } 

is there else should calling or doing listview appears once set itemsource? doesn't make sense why wouldn't though. nothing failing , working expected, other

the constructor not set itemssource, @ least not immediately. calls loadrequestlists starts async task set itemssource, @ point in future, itemssource set (whenever rest response received , ui thread happens run).

since constructors cannot await async task, need refactor code rest client runs (and finishes) before constructor, , reviewrequestspage take in list parameter. constructor can build openrequestcells , closedrequestcells , assign itemssource.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -