【www.gdgbn.com--WPF】

using System;
using System.Windows;
using System.Windows.Input;

namespace BrawDraw.Com.WPF.HandleEvents
{
    class HandleAnEvent
    {
        [STAThread]
        public static void Main()
        {
            Application app = new Application();

            Window win = new Window();
            win.Title = "Handle An Event";
            win.MouseDown += WindowOnMouseDown;
            win.KeyUp += WindowOnKeyUp;

            app.Run(win);
        }
        static void WindowOnMouseDown(object sender, MouseButtonEventArgs args)
        {
            Window win = sender as Window;
            string msg =
                string.Format("在位置({1})处按了{0}鼠标按钮",
                              args.ChangedButton, args.GetPosition(win));
            MessageBox.Show(msg, win.Title);
        }
        static void WindowOnKeyUp(object sender, KeyEventArgs args)
        {
            Window win = sender as Window;
            if (args.Key != Key.Return

本文来源:http://www.gdgbn.com/asp/14396/