Guest User

Untitled

a guest
May 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. foreach (KeyBinding binding in InputBindings)
  2. {
  3. if (binding.Command == ApplicationCommands.Copy)
  4. {
  5. MessageBox.Show(binding.Modifiers.ToString() + " + " + binding.Key.ToString());
  6. }
  7. }
  8.  
  9. Button b = new Button();
  10.  
  11. b.Command = ApplicationCommands.Copy;
  12.  
  13. List<string> gestures = new List<string>();
  14.  
  15. if (b.Command is RoutedCommand)
  16. {
  17. RoutedCommand command = (b.Command as RoutedCommand);
  18.  
  19. foreach (InputGesture gesture in command.InputGestures)
  20. {
  21. if (gesture is KeyGesture)
  22. gestures.Add((gesture as KeyGesture).DisplayString);
  23. }
  24. }
  25.  
  26. <Button Command="ApplicationCommands.New" Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}"></Button>
  27.  
  28. <Window.InputBindings>
  29. <KeyBinding Key="C"
  30. Modifiers="Control"
  31. Command="ApplicationCommands.Copy" />
  32. </Window.InputBindings>
Add Comment
Please, Sign In to add comment