private void ReportTimeHandler(object sender, ReportTimeEventArgs e) { FrameworkElement element = sender as FrameworkElement; string timeStr = e.ClickTime.ToLongTimeString(); 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.ClickTime = DateTime.Now; this.RaiseEvent(args); }