深入浅出WPF 第二部分(16)
8.3.2 自定义路由事件
private void timeButton_ReportTime(object sender, ReportTimeEventArgs e) { FrameworkElement element = sender as FrameworkElement; string timeStr = e.ClickTime.ToLongTimeString(); string content = string.Format("{0} 到达 {1}", timeStr, element.Name); if (element == this.grid_2) e.Handled = true; this.listbox.Items.Add(content); }