私は4つのクラスを持っています
コメント クラス:
public class comment
{
public string Username { get; set; }
public string Comment { get; set; }
public comment(string _username, string _comment)
{
this.Username = _username;
this.Comment = _comment;
}
}
ピン クラス:
public class Pin : PhoneApplicationPage
public List<comment> Comment_List;
public Pin(){
this.Comment_List = new List<comment>();
}
}
メッセージページ:
public partial class MessagePage : PhoneApplicationPage
{
Pin _Pin;
public MessagePage(Pin _pin)
{
this._Pin = _pin;
}
public void Refresh()
{
this.textbox1.Text = "";
foreach (comment c in this._Pin.List)
{
this.textbox1.Text += c.Username;
}
}
public void function()
{
//Call static function in another class to download new pin info
}
次に、静的関数は、PinList() という静的クラスを更新します。
ピンの静的リストが更新されると、PinList() クラスでイベントがトリガーされます。現在の MessagePage であるオブジェクトをアドレス指定して、Pin.comments の新しい値でテキスト ボックスを更新する関数を呼び出す方法。
つまり、私は持っています:
public class PinList
{
public ObservableCollection<Pin> list;
public static ObservableCollection<Pin> MainPinList = new ObservableCollection<Pin>();
public event PropertyChangingEventHandler PropertyChanged;
public PinList()
{
list = new ObservableCollection<Pin>();
list.CollectionChanged += listChanged;
((INotifyPropertyChanged)list).PropertyChanged += new PropertyChangedEventHandler(list_Property_Changed);
}
private void list_Property_Changed(object sender, PropertyChangedEventArgs args)
{
//Need to call
//MessagePage.Refresh();
}