Archive for May 29th, 2011

WPF: Enter/Esc key as shortcuts of OK/Cancel buttons

May 29, 2011

DialogBox is the easiest example that comes, but 99% of windows should have shortcuts for “OK” and “CANCEL” button.
The keys supposed to be the shortcut keys are always the same: ENTER and ESC key.
In XAML, you can set up this shortcut in button properties, via IsDefault and IsCancel properties.

Here is an example:


<Button Name="btnOK" IsDefault="True">OK</Button>
<Button Name="btnCancel" IsCancel="True">CANCEL</Button>

source: Dialog Boxes Overview

  • May 2011
    M T W T F S S
    « Apr   Jun »
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031  
  • .

    .Net Agile Antivirus Book C# Programming EntityFramework GTD Hyper-V LinQ MVVM Office Resharper SCRUM Security Sharepoint Silverlight SQLServer TFS ToDoList Unit Test VirtualBox Virtual PC Visual Studio VMware Windows7 WPF XeDotNet XML XPath

  • Follow

    Get every new post delivered to your Inbox.