Questions tagged [routed-commands]

WPF: Defines a command that implements ICommand and is routed through the element tree.

The WPF implementation of ICommand is the RoutedCommand class.

The main sources of input in WPF are the mouse, the keyboard, ink, and routed commands. The more device-oriented inputs use a RoutedEvent to notify objects in an application page that an input event has occurred. A RoutedCommand is no different. The Execute and CanExecute methods of a RoutedCommand do not contain the application logic for the command, but rather they raise routed events that tunnel and bubble through the element tree until they encounter an object with a CommandBinding. The CommandBinding contains the handlers for these events and it is the handlers that perform the command.

RoutedCommand Class

Commanding Overview

170 questions
0
votes
0 answers

How to change CommandTarget

I have class DesignerCanvas where I have RoutedCommand. public class DesignerCanvas { public static RoutedCommand SelectAll = new RoutedCommand(); public DesignerCanvas() { this.CommandBindings.Add(new…
rechandler
  • 756
  • 8
  • 22
0
votes
2 answers

WPF - Model method as Execute event for a command (NO RelayCommand or DelegateCommand)

I want to use a method which is not in the code behind for the command's Executed event and another for the CanExecute. I'm using a RoutedCommand and i do NOT want to use a Delegate Command or a Relay Command. What I got is a Commands class: public…
CodeMonkey
  • 11,196
  • 30
  • 112
  • 203
0
votes
1 answer

MenuItem in Window, CommandBinding in UserControl

I have a window:
benjamin.popp
  • 547
  • 1
  • 6
  • 20
0
votes
0 answers

How can I prevent CommandManager.InvalidateRequerySuggested() from executing automatically on key press?

CommandManager.InvalidateRequerySuggested() is called automatically every time a key has been pressed, when the focus has changed etc. I'd like to prevent this from happening under certain conditions (for example only call it when keys pressed are…
floele
  • 3,668
  • 4
  • 35
  • 51
0
votes
2 answers

How can I apply MVVM and Commands in this specific WPF situation?

I am having trouble with the MVVM pattern and Commands in my WPF app. The problem is not so much the MVVM pattern, but more the stuff that is going on on my GUI. I'll explain the situation: My app can DoStuff to some files. I have a class with a…
Matthijs Wessels
  • 6,530
  • 8
  • 60
  • 103
0
votes
2 answers

Can't figure out why button is disabled after adding a command

Edit: Here is the xaml for the window containing the command bindings.
Adam
  • 1,483
  • 4
  • 21
  • 50
0
votes
0 answers

my KeyBindings are eating the keypresses in the TextBox

I'm using the common RelayCommand class. Far up the visual tree, I have a number of my commands tied to UserControl.InputBindings with some common letter shortcuts. I also have a TextBox. However, when my TextBox has focus and I press any of the…
Brannon
  • 5,324
  • 4
  • 35
  • 83
0
votes
2 answers

WPF Routed Events Across Element Tree Branches

I am wondering what the correct mechanism to enable communication between controls in WPF is. My goal is to not use conventional events and have to manually wire them up. The default behavior of routed commands (tunneling, bubbling) seems to be…
JonS
0
votes
1 answer

Something similar to RoutedCommands, but for MVVM

I have a Command bound to my MainWindow via CommandBinding to the Delete key. I want that, depending on the context (which element is active), the same command would be translated to different delete commands that semantically delete things. In few…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
0
votes
3 answers

Show dialog box on shift double click

My WPF application has a TextBlock control in it. I want to display an "easter egg" when the user holds down the shift key and right double clicks on it. I've added a RoutedUiCommand to a static class in my application where I've defined all of the…
Tony Vitabile
  • 8,298
  • 15
  • 67
  • 123
0
votes
2 answers

Make command work only in part of a window

I have this xaml
Blablablaster
  • 3,238
  • 3
  • 31
  • 33
0
votes
2 answers

Why do my commandbindings only work if button is in toolbar?

I have a window with a toolbar which contains some buttons with commands. The Buttons stopped working since i replaced the toolbar with a stackpanel containing the buttons. In my understanding this shound not make any difference. The buttons still…
JCH2k
  • 3,361
  • 32
  • 25
0
votes
1 answer

How to get a RoutedCommand to a new ViewModel?

I have a relatively straightforward hierarchical data master-detail WPF window, developed using MVVM, where the Window points to a ViewModel which exposes as one of its properties the ViewModel for the detail view: Public Class…
Rob Perkins
  • 3,088
  • 1
  • 30
  • 51
0
votes
1 answer

How to define a global custom RoutedCommand?

I would like to use the same custom RoutedCommand for 2 buttons, which are in separate windows. In order to not repeat the code, i want to define the command somewhere in the app and bind it to both buttons. I thought of using Style to achieve that.…
rockeye
  • 2,765
  • 2
  • 30
  • 44
0
votes
2 answers

How to use the same RoutedCommand in distinct controls?

I a have 2 distinct UI elements in distinct files : a menuItem (in window.xaml) and a userControl (in foo.xaml). Both have exactly the same logic : they are enabled only if a condition is matched and call the same method. To code this logic, i use…
rockeye
  • 2,765
  • 2
  • 30
  • 44
1 2 3
11
12