private void TimeButton_ReportTime(object sender, ReportTimeEventArgs e) { FrameworkElement element = sender as FrameworkElement; string timeStr = e.ClickTime.ToString(); string content = string.Format("{0}到达{1}", timeStr, element.Name); this.listBox.Items.Add(content); }
//激发路由事件,借用Click事件的激发方法 protected override void OnClick() { base.OnClick(); ReportTimeEventArgs args = new ReportTimeEventArgs(ReportTimeEvent, this); args.ReportTime = DateTime.Now; this.RaiseEvent(args); }