Edit this page

Use Keyboard to Get User Response

When you have an application that uses RadWindow to get user response, it's common to alleviate the user experience by giving the user a chance to use the keyboard. For example, it's natural to accept response button by clicking the keyboard Enter button, and respectively to cancel response by pressing the ESC button. RadWindow addresses this issue by the ResponseButton attached property.

ResponseButton is an attached property that specifies the behavior of the default buttons part of RadWindow upon keystrokes.

  • Accept - Setting this value to any button part of the RadWindow will invoke the button's Click event whenever Enter is pressed.

  • Cancel - Setting this value to any button part of the RadWindow will invoke the button's Click event whenever ESC is pressed.

Here is an example of how to create a window that responds to Enter and ESC keyboard strokes. The example uses the RadWindow as a user control:

To learn more about how to use the RadWindow as user control read this topic.

<telerik:RadWindow x:Class="RadWindowSamples.RadWindowControl"
                   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&#13;                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&#13;                   xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"&gt;&#13;    <Grid>
            <RowDefinition Height="100" />
            <RowDefinition Height="*" />
        <Rectangle Grid.Row="0"
                   Height="100" />
        <StackPanel Grid.Row="1"
            <Button Click="OnButtonAcceptClicked"
                    telerik:RadWindow.ResponseButton="Accept" />
            <Button Click="OnButtonCancelClicked"
                    telerik:RadWindow.ResponseButton="Cancel" />

private void OnButtonAcceptClicked(object sender, RoutedEventArgs e)
    this.DialogResult = true;
private void OnButtonCancelClicked(object sender, RoutedEventArgs e)
    this.DialogResult = false;
Private Sub OnButtonAcceptClicked(sender As Object, e As RoutedEventArgs)
    Me.DialogResult = True
End Sub
Private Sub OnButtonCancelClicked(sender As Object, e As RoutedEventArgs)
    Me.DialogResult = False
End Sub

See Also

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article