表格控件 Spread WPF-Silverlight 本身内置了丰富的快捷键行为,用户可以同这些快捷键实现单元格选择,数据输入等行为,内置的快捷键如下表所示。
| Key | Action | Action Name |
| Ctrl + Z | Cancels the last user operation. |
Undo |
| Ctrl + Y | Repeats the last user operation. |
Redo |
| Ctrl + Down Arrow | Moves the active cell to the last row. |
NavigationBottom |
| Down Arrow | Moves the active cell down one cell. |
NavigationDown |
| End | Moves the active cell to the end of the row. | NavigationEnd |
| Ctrl + Right Arrow | Moves the active cell to the end of the row. | NavigationEnd |
| Ctrl + Home | Moves the active cell to the first cell in the control. | NavigationFirst |
| Home | Moves the active cell to the first cell in the row. | NavigationHome |
| Ctrl + Left Arrow | Moves the active cell to the first cell in the row. | NavigationHome |
| Ctrl + End | Moves the active cell to the last cell in the control. | NavigationLast |
| Left Arrow | Moves the active cell to the first cell in the row. | NavigationLeft |
| Tab | Moves the active cell right to the next cell and down to the first cell in the next row when the active cell is at the end of a row. | CommitInputNavigationTabNext |
| Page Down | Moves the active cell down to the next set of rows. | NavigationPageDown |
| Ctrl + PageUp | Moves to the previous sheet. | NavigationPreviousSheet |
| PageUp | Moves the active cell up to the next set of rows. | NavigationPageUp |
| Shift + Tab | Moves the active cell left and wraps to the end of the previous row when the active cell is the first cell in the row. | CommitInputNavigationTabPrevious |
| Right Arrow | Moves the active cell one cell to the right. | NavigationRight |
| Up Arrow | Moves the active cell up a cell. | NavigationUp |
| Ctrl + Up Arrow | Moves the active cell to the first cell in the column. | NavigationTop |
| Delete | Clears the data in the cell if it is not in edit mode. | Clear |
| Backspace | Clears the cell data if the cell is not in edit mode or moves a character to the left if the cell is in edit mode. | ClearAndEditing |
| Enter | Moves the active cell down a cell and takes the cell out of edit mode. | CommitInputNavigationDown |
| Shift + Enter | Moves the active cell up a cell and takes the cell out of edit mode. | CommitInputNavigationUp |
| Escape | Removes the current typed characters if the cell is in edit mode. | CancelInput |
| Shift + Left Arrow | Extends the selection one cell to the left of the active cell if the cell is not in edit mode (selects characters if the cell is in edit mode). | SelectionLeft |
| Shift + Right Arrow | Extends the selection one cell to the right of the active cell if the cell is not in edit mode (selects characters if the cell is in edit mode). | SelectionRight |
| Shift + Up Arrow | Extends the selection up one cell from the active cell if the cell is not in edit mode (selects cell characters if the cell is in edit mode). | SelectionUp |
| Shift + Down Arrow | Extends the selection down one cell from the active cell if the cell is not in edit mode (selects cell characters if the cell is in edit mode).. | SelectionDown |
| Shift + Home | Extends the selection from the active cell to the first cell in the row (selects cell characters if the cell is in edit mode). | SelectionHome |
| Shift + Ctrl + Left Arrow | Extends the selection from the active cell to the first cell in the row. | SelectionHome |
| Shift + End | Extends the selection from the active cell to the last cell in the row. | SelectionEnd |
| Shift + Ctrl + Right Arrow | Extends the selection from the active cell to the last cell in the row. | SelectionEnd |
| Shift + Page Up | Extends the selection one page up from the active cell. | SelectionPageUp |
| Shift + Page Down | Extends the selection one page down from the active cell. | SelectionPageDown |
| Shift + Ctrl + Up Arrow | Extends the selection from the active cell up to the first cell in the column. | SelectionTop |
| Shift + Ctrl + Down Arrow | Extends the selection from the active cell down to the last cell in the column. | SelectionBottom |
| Shift + Ctrl + Home | Extends the selection from the active cell to the first cell in the control. | SelectionFirst |
| Shift + Ctrl + End | Extends the selection from the active cell to the last cell in the control. | SelectionLast |
| Ctrl + C | Copies the selection to the Clipboard. | Copy |
| Ctrl + X | Cuts the selection to the Clipboard. | Cut |
| Ctrl + V | Pastes the data from the Clipboard. | Paste |
| Alt + Enter | Creates and moves to a new line if the cell is in edit mode. | InputNewLine |
但是,在运行Spread WPF-Silverlight应用程序时,我们会发现 Alt+Enter 键没用生效,其原因是在Silverlight中 Alt 键处理有些特别,所以,我们需要修改内置的快捷键行为来实现输入新行的功能,代码如下:
1: public MainPage()
2: {
3: InitializeComponent();
5: gcSpreadSheet1.View.KeyMap.Remove(new GrapeCity.Windows.SpreadSheet.UI.KeyStroke(Key.Enter,ModifierKeys.Alt));
6: gcSpreadSheet1.View.KeyMap.Add(new GrapeCity.Windows.SpreadSheet.UI.KeyStroke(Key.Enter, ModifierKeys.Control), SpreadActions.InputNewLine);
7: }