telerik - Show progress overlay while data bound list box is waiting for Async operation in C# Windows Phone 7 app (MVVM Light)? -


i have c# windows phone 7 app telerik data bound list box. data bound list box's itemssource property bound property in view model retrieves contents restful web service. logic read-only property follows:

is list property empty (first use)?

^ return empty list

^ retrieve list contents asynchronously

^ raise property changed event when retrieval completes

it works fine , want display progress overlay while async operation ongoing. using coding4fun toolkit's progress overlay control. problem don't know "plug in" right code show , hide progress overlay. tried doing view model below (see code below), progress overlay not visible. i'm guessing that's because not parented visible application page?

how can show progress overlay properly? note, if there's nice xaml way i'd know, otherwise i'll take can get.

    /// <summary>     /// async load of list return data bound contro.     /// </summary>     ///      async private void loadlistcontentsasync()     {         bool bisprogoverlayshowing = false;          if (!isloadinglist)         {             // set busy flag.             isloadinglist = true;              coding4fun.toolkit.controls.progressoverlay po = new coding4fun.toolkit.controls.progressoverlay();              po.content = "loading list";             po.show();              // set cleanup flag progress overlay.             bisprogoverlayshowing = true;              try             {                 // asynchronous load.                 list<string> bl = await this.getlistcontentsasync();                  _listcontents = bl.toobservablecollection();                  // raise property changed event handler.                 raisepropertychanged("listcontents");             }                         {                 // make sure loading flag cleared.                 isloadinglist = false;                  // hide progress overlay if showing.                 if (bisprogoverlayshowing)                     po.hide();             }         } // if (!isloadinglist)     } // async private void loadlistcontentsasync() 

you may find taskcompletionnotifier type useful. can source here; it'll in next version of asyncex library not in current release.

your vm property can of type itaskcompletionnotifier<observablecollection<string>> , can created passing task<observablecollection<string>> taskcompletionnotifierfactory.create. actual vm property can read-only.

once that's done, data binding code can use myvmproperty.result bind observablecollection<string> (the result property null until task completes). other data binding code can use myvmproperty.iscompleted bind boolean indicating whether operation completed. progress indicator can bind common boolean-to-visibility converter.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -