Questions tagged [routedcommand]
19 questions
78
votes
4 answers
MVVM Routed and Relay Command
What is the Difference between the RoutedCommand and RelayCommand ?
When to use RoutedCommand and when to use RelayCommand in MVVM pattern ?

user72799
- 781
- 1
- 6
- 3
8
votes
2 answers
Setting Command Target in XAML
I am having a hard time understanding the CommandTarget property for a RoutedCommand.
Basically, I have some static commands that have implementations in a user control (not the window). I create a commandbinding in the user control. If I declare…

kevindaub
- 3,293
- 6
- 35
- 46
4
votes
2 answers
WPF: Trigger RoutedCommands implemented in UserControl nested inside a ContentControl
How can I trigger routed commands implemented inside a UserControl which is nested inside a ContentControl?
What I basically have is an outer view (derived from UserControl) which contains:
1) A button which should trigger the command MyCommand:
The…

devar
- 95
- 8
2
votes
0 answers
WPF pass pressed key to command handler
I desire following behavior:
Pressing Ctrl + 1 causes selecting first item from list
Ctrl + 2 selects first two elements
And so on.
Currently I'm handling pressed keys by RoutedEvent, Window.CommandBindings and InputGesture. It works fine, but I…

mbednarski
- 758
- 1
- 9
- 17
1
vote
0 answers
In WPF how can you listen for changes to the text property of a RoutedUICommand without causing a memory leak?
In WPF, the RoutedUICommand is not a dependency object, nor does it implement INotifyPropertyChanged meaning if you were to bind its Text property to something in the UI such as a MenuItem's header, and Mode wasn't OneTime, you'd potentially get a…

Mark A. Donohoe
- 28,442
- 25
- 137
- 286
1
vote
2 answers
WPF - Coupling a GlobalResource to a ViewModel
I have a WPF application with a NotifyIcon defined in a ResourceDictionary that is added to Application.Current.Resources on App start.
I am using the MVVM-Light framework and I want to bind the Command properties of a ContextMenu.MenuItems on the…

Drammy
- 940
- 12
- 30
1
vote
1 answer
Command binding issue in CustomControl: CanExecute() fires, Execute() does not
I'm binding a button command, in a ControlTemplate, to an Execute() method in a CustomControl. I'm using a RoutedCommand, the CanExecute() fires, but the Execute() never does. When the CustomControl is placed in the main window, the code works as…

deathRacer
- 11
- 4
1
vote
1 answer
WPF menus with shortcuts and custom RoutedCommand
Im new to WPF so i might be missing something. I have a simple function in my MainWindow class called StartService. I wanted to add a menu item "Start Service" with a shortcut Ctrl+S to my application. I had to do the following:
In my MainWindow…

Tamer
- 876
- 2
- 10
- 22
1
vote
1 answer
How do the RoutedCommand constructors differ from eachother?
The RoutedCommand in WPF has 3 overloaded constructors.
Consider the following:
public static RoutedCommand AddTextFieldCommand = new RoutedCommand();
vs
public static RoutedCommand AddTextFieldCommand = new RoutedCommand("AddTextField",…

TimothyP
- 21,178
- 26
- 94
- 142
1
vote
1 answer
What is the use of tunneling the CommandBinding.previewcanexecute event ??
What is the use of tunneling the CommandBinding.previewcanexecute event ?
and bubbling the CommandBinding.canexecute event ?? How is it useful

venky
- 11
- 1
0
votes
3 answers
WPF Routed Command only fires sometimes
I have some RoutedCommands for commands like control-A, copy paste and they all work fine.
Then I added 4 more routedcommands to move object up down left and right in the canvas using arrowkeys, they sometimes works and sometime doesn't. At first I…

Ling Xing
- 181
- 2
- 14
0
votes
1 answer
RoutedCommands bound by sub elements never fire
I'm trying to get my head around RoutedCommands in WPF. I like how they decrease coupling between different UI elements and the models but I can't seem to make the bindings work for custom controls that are children to the window. I guess this will…

Jonas Rembratt
- 1,550
- 3
- 17
- 39
0
votes
1 answer
Catel application-wide commands only in focused control
Is it possible to register an application command in Catel which would fire only when specific control has a focus?
For example, in the Catel.Examples.WPF.Commanding example,…
user3188639
0
votes
2 answers
WPF commands globally available
I have a Window element which contains a RibbonMenue. Within this Window there are some UserControls. In one of the UserControl is a DataGrid. I created a ICommand which lets me add and delete rows from the DataGrid.
The problem is that I somehow…

Hans Vader
- 19
- 6
0
votes
1 answer
RoutedCommand for multiple Windows
been looking through Google results for quite some hours now and all i was finding were examples of how to use RoutedCommand to catch MouseClicks and Keyboard Shortcuts to do the same actions.
I've read some sources about RoutedCommand like MSDN and…

Fruckley
- 3
- 3