CommandShortcut

in namespace DotVVM.BusinessPack.Controls

Renders a control that triggers a command for a specific combination of keys.

Usage & Scenarios

An invisible control which allows to trigger a command in the viewmodel for a key shortcut.

Sample 1: Basic Usage

Use the Ctrl, Shift and Alt properties to specify modifiers for the shortcut, and use the Key property to specify the shortcut key.

The Command property specifies a command in the viewmodel which is triggered when the key combination is hit.

<p>Press CTRL + Shift + S to Save</p>
<bp:CommandShortcut Ctrl="true"
                    Shift="true"
                    Alt="false"
                    Key="S"
                    Command="{command: Save()}" />

<p>Last save: {{value: LastSave}}</p>
using System;
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.CommandShortcut.sample1
{
    public class ViewModel : DotvvmViewModelBase
    {
        public string LastSave { get; set; } = "Not saved yet.";

        public void Save()
        {
            LastSave = DateTime.Now.ToString("HH:MM:ss");
        }
    }
}

Properties

Name Type Description Notes Default Value
property icon Alt Boolean Gets or sets whether the Alt key must be pressed together with the Key.
attribute
inner element
static value
bindable
default
False
property icon Attributes Dictionary<String,Object>
attribute
inner element
static value
bindable
default
null
property icon ClientIDMode ClientIDMode Gets or sets the client ID generation algorithm.
attribute
inner element
static value
bindable
default
Static
property icon Ctrl Boolean Gets or sets whether the Control key must be pressed together with the Key.
attribute
inner element
static value
bindable
default
False
property icon DataContext Object Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value.
attribute
inner element
static value
bindable
default
null
property icon Enabled Boolean Gets or sets whether the Command is triggered when the shortcut is pressed.
attribute
inner element
static value
bindable
default
True
property icon ID String Gets or sets the unique control ID.
attribute
inner element
static value
bindable
default
null
property icon InnerText String Gets or sets the inner text of the HTML element.
attribute
inner element
static value
bindable
default
null
property icon Key ShortcutKeys Gets or sets the shortcut key to be pressed.
attribute
inner element
static value
bindable
default
0
property icon Shift Boolean Gets or sets whether the Shift key must be pressed together with the Key.
attribute
inner element
static value
bindable
default
False
property icon Visible Boolean Gets or sets whether the control is visible.
attribute
inner element
static value
bindable
default
True

Events

Name Type Description
event icon Command Command Gets or sets the command triggered when the shortcut is pressed.

HTML produced by the control