我有 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();
}