none
Hotkeys - Shortcuts

    Question

  • Hello! I am trying to set like hotkeys. I mean, I have an .NET app and I must to migrate to SL4. The older one had shortcuts, for example, it has a button that conteins the word "Exit" and it shows the 'C' and if I press ctrl+C, it shows me the module; and I have to do the same in SL4.

     

    First, I cant do that the 'C' be underlined. Second, that shortcut doesnt work.

     

    Thanks in advance.

    Shirivo

    Monday, November 28, 2011 9:09 AM

Answers

  • I used Content="^Cancel"  to underline 'C' and AutomationProperties.AccessKey="A" to create the hotkey/shorytcut.

    It is working correctly.

     

    <Button IsEnabled="true" IsTabStop="true" Content="^Cancel" AutomationProperties.AccessKey="A" Click="CmdCancel_Click"/>
    
    Thursday, December 08, 2011 4:59 PM

All replies

  • Hi

    please refer to the link below:

    <UserControl x:Class="SilverlightApplication154.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
    
        <Grid x:Name="LayoutRoot" Background="White">
            <TextBlock Text="C" TextDecorations="Underline" Margin="109,83,235,199" />
        </Grid>
    </UserControl>
    

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    
    namespace SilverlightApplication154
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
                this.KeyUp += new KeyEventHandler(MainPage_KeyUp);
            }
    
            void MainPage_KeyUp(object sender, KeyEventArgs e)
            {
                if (e.Key == Key.C)
                {
                    if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
                    {
                        MessageBox.Show("Ctrl+C");
                    }
                }
            }
        }
    }
    

    Hope helpful.

    Wednesday, November 30, 2011 1:59 AM
  • I used Content="^Cancel"  to underline 'C' and AutomationProperties.AccessKey="A" to create the hotkey/shorytcut.

    It is working correctly.

     

    <Button IsEnabled="true" IsTabStop="true" Content="^Cancel" AutomationProperties.AccessKey="A" Click="CmdCancel_Click"/>
    
    Thursday, December 08, 2011 4:59 PM
  • thanks Otomii Lu...  but it did not work. i posted the correct code.

    Thursday, December 08, 2011 5:00 PM
  • Hi shirivo,

    THX for sharing your solution~

    Thursday, December 08, 2011 7:56 PM