wpf鼠标点击事件|WPF鼠标及按键检测

时间:2015-04-15  来源: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

wpf鼠标点击事件|WPF鼠标及按键检测

http://m.bbyears.com/asp/14396.html

推荐访问:
相关阅读 猜你喜欢
本类排行 本类最新