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
7
votes
1 answer

RoutedCommands Executed and PreviewExecuted events

My problem is that I would like to handle a commands in multiple places. For instance I have my custom UserControl where a Button is bound to some command. I have a command binding in that control but I also have a command binding in a Window which…
serine
  • 1,338
  • 14
  • 24
7
votes
1 answer

How to intercept execution of a RoutedCommand within the view?

In a WPF / MVVM application, I am trying to find a code-efficient way to set the main view cursor to Cursors.Wait prior to any lengthy operation and to restore it to the default cursor after completion. Since all operations are invoked using routed…
Tim Coulter
  • 8,705
  • 11
  • 64
  • 95
7
votes
1 answer

Separating views, command presentation (Text, Icon) and command logic (Execute, CanExecute)

If TL;DR: see the last paragraph. Pure WPF "suggests" putting presentation (controls, text, icons) into views and command logic (Execute, CanExecute methods) into code-behind. Besides putting logic both into views (CommandBindings) and code-behind…
Athari
  • 33,702
  • 16
  • 105
  • 146
6
votes
3 answers

Loopback in Route table

I and working on a project to create a WAN emulator using FreeBDS in a VMWare guest configured to route traffic between the host operating system and its normal gateway router. I plan to modify the route table on the host so that it's traffic is…
Gil
  • 128
  • 1
  • 1
  • 7
5
votes
4 answers

WPF using custom RoutedUICommands or simple event handlers?

I was talking to someone today about picking a design pattern for how to handle logic in their WPF program and hoping that the SO community can help with further advice to make the decision easier. What factors in favour of commands outweigh the…
Andy Dent
  • 17,578
  • 6
  • 88
  • 115
5
votes
4 answers

Do WPF Routed Commands solve a problem or make it worse?

From what I understand, the goal of the Command pattern is to help separate UI interaction from application logic. With properly implemented commands, a click on a "Print" menu item might result in a chain of interaction like this: (button)…
OwenP
  • 24,950
  • 13
  • 65
  • 102
5
votes
1 answer

RoutedUICommand within MVVM

I am struggling with MVVM in my application. I have there a TabControl whose every Tab hosts a control that allows somehow editing a file. For instance, text files or images. Each control is bound to a class from ViewModel area (as is depict at the…
Slávek Rydval
  • 244
  • 2
  • 10
5
votes
2 answers

RoutedUICommand PreviewExecuted Bug?

I'm building an application using the MVVM design pattern and I want to make use of the RoutedUICommands defined in the ApplicationCommands class. Since the CommandBindings property of a View (read UserControl) isn't a DependencyProperty we can't…
elmar
  • 103
  • 7
5
votes
4 answers

multi key gesture in wpf

I have a RoutedUICommand called Comment Selection. I need to add an input gesture for this command as it is in VIsual Studio, ie. (Ctrl+K, Ctrl+C). How can I do this? Plz help me. (Keep VS functionality in mind). Regards, Jawahar
jawahar
  • 171
  • 2
  • 5
4
votes
1 answer

Command routing for Keyboard shortcuts

Basically I want to create a keyboard shortcut which is valid within the scope of a window, and not just enabled when focus is within the control that binds it. in more detail.... I have a window which has 3 controls: a toolbar a textbox a Custom…
Sprotty
  • 5,676
  • 3
  • 33
  • 52
4
votes
2 answers

How to debug commands

How do I debug a RoutedUICommand when the associated UIElement is disabled. For example, consider the ContextMenu. Since it exists in a different VisualTree, a command written with the menu item might not be able to propagate from it to the parent…
sudarsanyes
  • 3,156
  • 8
  • 42
  • 52
4
votes
2 answers

Objection to MVVM pattern is lack of IDE support - do any of the frameworks help with that?

Some of our developers don't like the commanding in MVVM because there is no support in VS2010 IDE to help you navigate from the Command binding in xaml to the actual code implementing the behavior. With code-behind, you can right-click and select…
tobewan
  • 189
  • 2
  • 9
4
votes
1 answer

Passing ListView Items to Commands using Prism Library

I'm trying to execute methods based on listview items data. In addition to that, the button, which triggers the command, should only be enabled, if "CanExecute" method of the listview item returns true. Both methods, "MyCommand" and "CanExecute",…
user1011394
  • 1,656
  • 6
  • 28
  • 41
4
votes
1 answer

What is the best approach to binding commands in a ViewModel to elements in the View?

Anyone who has tried to implement RoutedCommands in WPF using M-V-VM has undoubtedly run into issues. Commands (non-UI commands that is) should be implemented in the ViewModel. For instance if I needed to save a CustomerViewModel then I would…
Micah
  • 111,873
  • 86
  • 233
  • 325
4
votes
1 answer

Show InputGestureText as a tooltip for a Button

A have a Button with a Command. I want to display the InputGestureText as a ToolTip for every button that contains a command. This is what I tried:
Nicke Manarin
  • 3,026
  • 4
  • 37
  • 79
1
2
3
11 12