テンプレート Windows8(C#) 2ページテンプレート データ http://textt.net/sworc/20120924055943.txt JSON処理 JSON.net の文字列から内容の参照のバターンサンプルがわりと全く無かったので作成 Json.NET - James Newton-King BasicPage1.xaml.cs 内では、直接 DataContext にセットしているので、その時点でバインドされて表示されます。
<!-- HttpClient で取り出すデータの為に追加した TextBox -->
<TextBox
x:Name="TextBox1"
HorizontalAlignment="Left"
Height="26"
Margin="128,34,0,0"
Grid.Row="1"
TextWrapping="Wrap"
Text="{Binding Path=id}"
VerticalAlignment="Top"
Width="143">
</TextBox>
BasicPage1.xaml.cs
namespace App74
{
public sealed partial class BasicPage1 : App74.Common.LayoutAwarePage
{
private HttpClient httpClient;
private string responseBodyAsText;
private Class1 class1 = new Class1();
public BasicPage1()
{
this.InitializeComponent();
this.init();
}
private async void init()
{
httpClient = new HttpClient();
httpClient.MaxResponseContentBufferSize = 256000;
httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");
HttpResponseMessage response = await httpClient.GetAsync("http://textt.net/sworc/20120924055943.txt");
response.EnsureSuccessStatusCode();
responseBodyAsText = await response.Content.ReadAsStringAsync();
class1 = JsonConvert.DeserializeObject<Class1>(responseBodyAsText);
TextBox1.DataContext = class1;
// class1.NotifyPropertyChanged("id");
}
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
{
}
protected override void SaveState(Dictionary<String, Object> pageState)
{
}
}
}
オブジェクトのすべてのプロパティが変更されたことを示すには、PropertyChangedEventArgs の PropertyName プロパティに String.Empty を使います HttpClient のサンプルソースは、こちらから参照できます。 Microsoft のドキュメントならこのページです。 バイント用のクラス : Class1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
namespace App74
{
class Class1 : INotifyPropertyChanged
{
public Class1()
{
}
public event PropertyChangedEventHandler PropertyChanged;
public string id { get; set; }
public void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this,
new PropertyChangedEventArgs(propertyName));
}
}
}
}
※ id のみ実装しています ドキュメントリンク windows8
|
|
【オワコンの最新記事】
- tiktok > Stable Diffusion : まあ、とにかく凄い今時の頂点系
- Windows 8.1 + Visual Studio 2013 + WebGL + Three.js v65
- Microsoft Visual Studio 2010 のエミュレータは localhost で PC にアクセスできてた。
- Windows Phone で Zune を終了しても実機デバッグはできる( つまり、カメラが使える )
- Windows Phone SDK 8.0 がリリースされました。高橋 忍氏のブログをチェックするといいと思います
- App クラスを介してページ間の参照 / Windows Phone(C#)
- Windows8 の最新版で、C#のテンプレート(Windows ストア)で、ページを追加すると固まるというバグがあるので、テンプレートを作って回避しています。
- 黒子のバスケが始まるまでに Windows Phone の開発環境を作る
- AIR + Papervision3D でメタセコイアの 3D キャラを遊ぶサンプルパッケージ
- Windows8(JavaScript Metro Style 導入) 関連リンク
- Windows 8 Release Preview のコントロールパネルの Flash Player 設定マネージャ
- Windows8 の XMLHttpRequest の POST メソッドのテストの為に、超簡易掲示板を授業中に作成
- AIR+FLARToolkitサンプル開発キット / collada(dae)とメタセコイア(mqo)ローダ実装済
- AIR Flex4 で WEB カメラを最も簡単に実装する方法
- Windows8 + LiveSDK のサンプルコードの実行
- WindowsConsumerPreview やその他の環境で、Microsoft の Live SDK を試す為の情報
- Adobe AIR Flex をだれでも簡単に作成できるパッケージ : ★ 超シンプル FLV プレーヤー ★
- アプリケーションバーを追加する : Win8 Metro(JS)
- Spark のスキンを使った時のウインドウサイズ変更オペレーション : Adobe AIR Flex
- FLVプレーヤーをもっと簡単に。VideoDisplay を VideoPlayer に変更する : Adobe AIR Flex




























