我有这个JSON对此我从web服务在我的代码执行GET,并解析成一个字典。
{
"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"]));
}
我很好奇,我怎么能实现的IObservable和INotifyPropertyChanged接口的字典对象,并绑定值在XAML UI元素就像在XAML每个区块都会有名字,P1和P2。 任何建议PLZ?