i have json doing webservice in code , parsing dictionary.
{ "x-yz-111/ab.cd": { "p1": "f", "p2": "43.46" }, "x-yz-112/ab.cd": { "p1": "f", "p2": "8.02" }, "x-yz-113/ab.cd": { "p1": "f", "p2": "9066.58" }, "x-yz-114/ab.cd": { "p1": "f", "p2": "6.00" }, "x-yz-115/ab.cd": { "p1": "f", "p2": "6.00" }, "x-yz-116/ab.cd": { "p1": "f", "p2": "10.00" }} using windows.data.json; private async void getjson_click(object sender,routedeventargs e) { var client=new httpclient(); client.maxresponsebuffersize=1024*1024; var response= await client.getasync(new uri(the url here)); var result = await response.content.readasstringasync(); var jobj = jobject.parse(result); var dict = jobj.children() .cast<jproperty>() .todictionary(p => p.name, p => new tuple<string, string>((string)p.value["p1"], (string)p.value["p2"])); }
i curious how can implement iobservable , inotifypropertychanged on dict object , bind values ui elements in xaml each tile in xaml have name,p1 , p2 . suggestions plz?
first write class objects , implement inotifypropertychanged.
public class yournewclass : inotifypropertychanged { private string _name; public string name { { return _name; } set { _name = value; onpropertychanged("name"); } } // same other 2 properties }
now collection not dictionary , observablecollection . in getjson_click method load data new objects of type yournewclass.
Comments
Post a Comment