30 lines
819 B
C#
30 lines
819 B
C#
using System.Windows;
|
|
using System.Windows.Input;
|
|
|
|
namespace WPF路由事件_1_引发路由事件;
|
|
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
// 等同于xaml上触发事件
|
|
GridImage2.MouseUp += GridImage_OnMouseUp;
|
|
|
|
// 也可以这样创建事件
|
|
GridImage2.AddHandler(MouseUpEvent, new MouseButtonEventHandler(GridImage_OnMouseUp));
|
|
|
|
// 移除事件
|
|
GridImage2.MouseUp -= GridImage_OnMouseUp;
|
|
GridImage2.RemoveHandler(MouseUpEvent, new MouseButtonEventHandler(GridImage_OnMouseUp));
|
|
}
|
|
|
|
private void GridImage_OnMouseUp(object sender, MouseButtonEventArgs e)
|
|
{
|
|
Console.WriteLine(e.Timestamp);
|
|
}
|
|
} |