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
2
votes
0 answers

WPF: SelectionChanged command gets fired on unload of UserControl

I am working on wizard kind of application, where I am maintaining the wizards in a list named List. I have used same UserControl UCView to render two different pages by simply tweaking the ViewModel values stored in…
Jayakrishnan
  • 4,232
  • 2
  • 23
  • 35
2
votes
3 answers

How to set WPF ApplicationCommands in code behind

I know how to set default ApplicationCommands commands in WPF in order to enable simple cut, copy, and paste operations via ContextMenu. However I need to be able to do this in the code behind so that I can assign the commands dynamically as my…
ChrisUK
  • 547
  • 8
  • 17
2
votes
0 answers

Why is my custom RoutedCommand not Bubbling up all Visual Parents?

A contrived example: Window -Grid --StackPanel ---Slider ---Slider Both sliders use Interaction.Triggers to send a custom-command defined in codebehind. Each of the visual parents define a CommandBinding to tie this Test command and invoke an…
opf
  • 63
  • 4
2
votes
1 answer

WPF application with context sensitive toolbar

I want to design an application much like Visual studio where the toolbars are context sensitive to the workspace area and their are common toolbars which have context sensitive functionality like cut, copy, paste (for these I can have application…
Bhupendra
  • 1,725
  • 22
  • 30
2
votes
2 answers

Using RoutedCommand in Main Window with User Controls

i'm trying to understand how Routed Commands works, but I've got a problem. I've created a Main Window with Button and ItemControl with UserControls as its Item template.
Ann Mary
  • 68
  • 6
2
votes
2 answers

WPF Architecture Confusion RE: Routed Commands, Events, and Gestures

In learning WPF, I've been reading scads of books and web sites. One thing that seems to keep evading me is how we are supposed to properly wire up RoutedCommands. In one article, the author pointed out that the codebehind for your XAML files is…
Mike Hofer
  • 16,477
  • 11
  • 74
  • 110
2
votes
2 answers

How to use the viewmodel, model, command classes with Data Binding in the Window.Resources tags?

If WPF MVVM is supposed to have no code behind, why does when you use the ICommand, do you need the DataContext property instantiated in the Window.xaml.cs code behind? I've watched and followed side by side YouTube WPF MVVM, data binding, ICommand,…
FlazzG
  • 21
  • 3
2
votes
1 answer

When will the CanExcute event be raised by the CommandSource

When will the CanExecute event be ideally raised by the control that realizes the ICommandSource interface? I tried to add a breakpoint to the handler to check when it is getting raised and it seems to be executed whenever the control is rendered on…
sudarsanyes
  • 3,156
  • 8
  • 42
  • 52
2
votes
1 answer

What is the benefit of using RoutedCommands in WPF

I am struggling to see what the benefits are of using Custom RoutedCommands in WPF over a standard event. Suppose I have a custom RoutedCommand declared in a static class like so: public static readonly RoutedCommand Foo = new RoutedCommand(); And…
William
  • 1,837
  • 2
  • 22
  • 36
2
votes
2 answers

WPF Routed Command Tunneling

I'd like to implement a routed command that tunnels to a user control in my WPF application. My understanding is that routed commands, like routed events can propagate up and down the visual tree to find the appropriate handler, however I cannot…
user1400716
  • 1,126
  • 5
  • 13
  • 32
2
votes
1 answer

How to bind a RelayCommand(MVVM) to a RoutedCommand? (CommandBinding)

I want to create a custom class of a CommandBinding, where a RelayCommand of my ViewModel is executed when the RoutedCommand is executed. Currently there is only the possibility to create CommandBindings which have Executed methods in the codebehind…
Henk
  • 750
  • 10
  • 21
2
votes
1 answer

DelegateCommand vs RoutedCommand and gestures - WPF

is there anyway for DelegateCommand's to support gestures when building a composite WPF app? I'm trying to create a command used by a MenuItem and also a Button, which can be accessed through a keyboard shortcut, but which sits inside a class in a…
devdigital
  • 34,151
  • 9
  • 98
  • 120
2
votes
1 answer

WPF: Change the text of menuitem on context menu

I have ContextMenu in XAML with the following MenuItem: I'd like to change the Header of MenuItem by somehow changing the Text of RoutedCommand. And I'd like to do that in…
bh213
  • 6,343
  • 9
  • 43
  • 52
2
votes
1 answer

Why does command binding to a button have different behavior than command binding a menu item?

Consider the following example with a menu and a button:
Billy ONeal
  • 104,103
  • 58
  • 317
  • 552
2
votes
0 answers

wpf commandtarget for routeduicommand with nested controls

I have a main window wich consist mainly of a fluidribbon control as menu and a statusbar. It also has a content control where i load views (usercontrols). Im using RoutedUICommand's to execute button events from my Ribbon buttons. Depending on the…
Azazel
  • 191
  • 3
  • 15