Silverlight的组合键、快捷键(热键)调用方法

在Silverlight2.0、Silverlight3.0、Silverlight 4.0版本中实现组合键、快捷键(热键)是非常简单的。

但是由于Silverlight是运行于IE之中,所以很多组合键、快捷键(热键)都被IE占用,很遗憾目前还没有阻止IE的方案。

我们只能使用有限的组合键、快捷键(热键),以下是使用方法:

void MainPage_KeyDown(object sender, KeyEventArgs e)
{
    ModifierKeys keys = Keyboard.Modifiers;
    if ((e.Key == Key.G) && keys == ModifierKeys.Control)
    {
        MessageBox.Show("你按下了Ctrl+G组合键!");
    }
}

热键说明:

None
没有按下任何修饰符。

Alt
Alt 键已按下。

Control
Ctrl 键已按下。

Shift
Shift 键已按下。

Windows
Windows 徽标键已按下。

Apple
Apple 键(也称作"Open Apple 键")已按下。

ModifierKeys 枚举值:

namespace System.Windows.Input
{
// Summary:
//     Specifies the set of modifier keys.
    [Flags]
public enum ModifierKeys
    {
// Summary:
//     No modifiers are pressed.
        None = 0,
//
// Summary:
//     The ALT key is pressed.
        Alt = 1,
//
// Summary:
//     The CTRL key is pressed.
        Control = 2,
//
// Summary:
//     The SHIFT key is pressed.
        Shift = 4,
//
// Summary:
//     The Windows logo key is pressed.
        Windows = 8,
//
// Summary:
//     The Apple key (also known as the "Open Apple key") is pressed.
        Apple = 8,
    }
}

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/dotfun/archive/2010/01/11/5178267.aspx

posted on 2010-06-17 16:32  chuncn  阅读(426)  评论(0编辑  收藏  举报

导航