This is a migrated thread and some comments may be shown as answers.

RadButton AccessText Hotkey

4 Answers 323 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
Daniel Schuessler
Top achievements
Rank 1
Daniel Schuessler asked on 20 Apr 2010, 03:43 PM
How would you implement a hotkey for the Approve RadButton in the following code snippet?

          <telerik:RadButton Name="btApproveReport"  Click="btApproveReport_Click"  Margin="10,0,10,0" Width="Auto" HorizontalContentAlignment="Center" MaxHeight="30" VerticalContentAlignment="Center" > 
            <telerik:RadButton.Content> 
              <StackPanel Orientation="Horizontal" Margin="4 0"
                <TextBlock Text="Approve"   Foreground="DarkGreen" FontSize="12" /> 
                <Image Source="pack://application:,,,/Resources/CheckMark.png" Margin="5 0 0 0" Height="16" Width="16" /> 
              </StackPanel> 
            </telerik:RadButton.Content> 
          </telerik:RadButton> 

4 Answers, 1 is accepted

Sort by
0
Miro Miroslavov
Telerik team
answered on 23 Apr 2010, 08:43 AM
Hi Daniel Schuessler,

The best approach for handing hotkeys is using Commands like follows.

<Window.InputBindings>
        <KeyBinding Modifiers="Control" Key="a" Command="ApplicationCommands.Open"/>
    </Window.InputBindings>
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Open" Executed="CommandBinding_Executed" CanExecute="CommandBinding_CanExecute"/>
    </Window.CommandBindings>
    <Grid>
        <telerik:RadButton Name="btApproveReport" Command="ApplicationCommands.Open"  Margin="10,0,10,0" Width="Auto" HorizontalContentAlignment="Center" MaxHeight="30" VerticalContentAlignment="Center" >
            <telerik:RadButton.Content>
                <StackPanel Orientation="Horizontal" Margin="4 0">
                    <TextBlock Text="Approve"   Foreground="DarkGreen" FontSize="12" />
                    <!--<Image Source="pack://application:,,,/Resources/CheckMark.png" Margin="5 0 0 0" Height="16" Width="16" />-->
                </StackPanel>
            </telerik:RadButton.Content>
        </telerik:RadButton>
    </Grid>


And in the code behind:

private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
    //Your click handler.
}
 
private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
    e.CanExecute = true;
}

Hope will works for you.

All the best,
Miro Miroslavov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Subha
Top achievements
Rank 1
answered on 08 Dec 2011, 11:23 PM
Is there similar procedure for Silverlight?  We are looking to add some hot keys for button click events.
Thanks,
Subha
0
Subha
Top achievements
Rank 1
answered on 08 Dec 2011, 11:23 PM
Is there similar procedure for Silverlight?  We are looking to add some hot keys for button click events.
Thanks,
Subha
0
Petar Mladenov
Telerik team
answered on 13 Dec 2011, 07:05 PM
Hi Subha,

 Please check out the attached project which follows the approach described in this help article and let us know if it satisfies you.

Regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Buttons
Asked by
Daniel Schuessler
Top achievements
Rank 1
Answers by
Miro Miroslavov
Telerik team
Subha
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or