using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace PhoneApp7
{
public class JsonData
{
public JsonData()
{
// 3つ入る場所を確保(中は null)
this.ListBoxContent = new string[3];
}
public bool CheckBoxSetting { get; set; }
public int ListBoxSetting { get; set; }
public string[] ListBoxContent { get; set; }
public bool RadioButton1Setting { get; set; }
public bool RadioButton2Setting { get; set; }
public bool RadioButton3Setting { get; set; }
}
}
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Diagnostics;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace PhoneApp7
{
public class Class1 : INotifyPropertyChanged
{
// チェックボックス用プロパティ// ※ TwoWay でセットされる様子をチェックする為にコードを記述しています
private bool _CheckBoxSetting;
public bool CheckBoxSetting {
get {
return _CheckBoxSetting;
}
set {
_CheckBoxSetting = value;
Debug.WriteLine("CheckBoxSetting にデータがセットされました" + value);
}
}
public Class1()
{
WebClient webClient = new WebClient();
webClient.DownloadStringCompleted +=
new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
// 外部サービスから文字列を取得// {"CheckBoxSetting": true, "ListBoxSetting": 2}
webClient.DownloadStringAsync(new System.Uri("http://textt.net/sworc/20120929111044.txt"));
}
protected virtual void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Debug.WriteLine(e.Error.Message);
});
}
else
{
Debug.WriteLine("オーバーライド元を実行");
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this,
new PropertyChangedEventArgs(propertyName));
}
}
}
}