7,655
社区成员
发帖
与我相关
我的任务
分享
public delegate void NoticeEeventHandler(object sender, NoticeEventArgs e);
public class SyncCompleteNotice
{
string curr_NoticeTag;
public event NoticeEeventHandler NoticeTest;
public string Curr_char
{
get { return curr_NoticeTag; }
set
{
if (NoticeTest != null)
{
NoticeEventArgs myenen = new NoticeEventArgs(value);
curr_NoticeTag = myenen.NoticeTag;
this.NoticeTest(this, myenen);
}
}
}
}
public class NoticeEventArgs : EventArgs
{
public string NoticeTag;
public NoticeEventArgs(string noticeTag)
{
this.NoticeTag = noticeTag;
}
}
在app.cs中,public static SyncCompleteNotice SyncNotice = new SyncCompleteNotice();
然后各个页面的OnNavigatedTo中注册事件,App.SyncNotice.NoticeTest += SyncNotice_NoticeTest;
还要记得在OnNavigatedFrom中取消注册事件,App.SyncNotice.NoticeTest -= SyncNotice_NoticeTest;
完事