c# - Add MobileServiceCollection to ObservableCollection -
i want know how insert mobileservicecollection windows azure observablecollection json web service
private observablecollection<addressdetail> _hererestaddressdetail = null; public observablecollection<addressdetail> hererestaddressdetail { { return _hererestaddressdetail; } set { this.setproperty(ref this._hererestaddressdetail, value); } } private async void updatetransportdetail() { try { webclient client = new webclient(); client.downloadstringcompleted += (s, e) => { if (e.error == null) { rootobjectdetail result = jsonconvert.deserializeobject<rootobjectdetail>(e.result); hererestaddressdetail.clear(); hererestaddressdetail.insert(0,result); } else { isfailed = visibility.visible; isfailedmessage = "can't data web server, please refresh , make sure internet data connected"; } }; client.downloadstringasync(new uri(hreftext + transportdetailurl)); hererestaddressdetail = await addresstable.tocollectionasync(); } catch (exception) { isfailed = visibility.visible; isfailedmessage = "something wrong happen, please refresh"; } }
and try add azure data next entry of hererestaddressdetail (since first json web service) this
hererestaddressdetail = await addresstable.tocollectionasync();
but replace data json not adding it, how can make appear json data also?
not sure if question still actual, can replace while collection
hererestaddressdetail = new observablecollection<addressdetail>(await addresstable.tocollectionasync());
or (i'd recommend way) grab optimizedobservablecollection ( example, here: http://www.pedrolamas.com/2013/05/08/cimbalino-windows-phone-toolkit-updated-to-v2-3-0/ ) , use like
hererestaddressdetail.replacewith(await addresstable.tocollectionasync()); // replace or hererestaddressdetail.addrange(await addresstable.tocollectionasync()); // add
Comments
Post a Comment