windows phone 8 - XAML ProgressRing doesn't stop -


my problem progressring running time. use mvvm. progressring active when app new data.

i have code in vm (i updated viewmodel):

public class mainpageviewmodel : observablecollection<admodel>, isupportincrementalloading{     private visibility _loadervisibility;     public visibility loadervisibility     {         { return _loadervisibility; }         private set         {             _loadervisibility = value;          }}     public iasyncoperation<loadmoreitemsresult> loadmoreitemsasync(uint count)     {         coredispatcher coredispatcher = window.current.dispatcher;          return task.run<loadmoreitemsresult>(async () =>         {             await coredispatcher.runasync(coredispatcherpriority.normal,                 () =>                 {                     this.loadervisibility = visibility.visible;                 });              var newads = new observablecollection<admodel>();              do{newads = await loadads();//get data api}             while (newads == null);              await coredispatcher.runasync(coredispatcherpriority.normal,                 () =>                 {                     foreach (admodel item in newads)                     {                         this.add(item);                     }                     this.loadervisibility = visibility.collapsed;                 });              return new loadmoreitemsresult() { count = count };         }).asasyncoperation<loadmoreitemsresult>();}} 

first need fire propertychanged event when change loadervisibility property, ui can notified of new value. see example on how implement property change notification.

the loadervisibility property should (this vm class needs implement inotifypropertychanged interface, have propertychanged event).

private visibility _loadervisibility;  public visibility loadervisibility  {     { return _loadervisibility; }     set      {         _loadervisibility = value;         onpropertychanged(new system.componentmodel.propertychangedeventargs("loadervisibility"));     } } 

second, not set progressring's visibility property code behind, break data binding wire in xaml.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -