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
1
vote
3 answers

WPF Routed Command with Bindings per-Tab

I intended to disable and enable the Buttons outside the TabControl, just like those inside the TabItem when the current tab is changed. But the CommandBindings of the TabItem do not seem to impact "up" the visual tree. What is the right way to do…
Jerry Nixon
  • 31,313
  • 14
  • 117
  • 233
1
vote
1 answer

WPF: Using RoutedCommand in Modal Windows the MVVM way

I have a WPF application which I am trying to implement in a MVVM pattern (as much as possible). One of my view models opens a child window with code like this: SomeChildWindow childWin = new SomeChildWindow(); childWin.DataContext =…
DaveS
  • 895
  • 1
  • 8
  • 20
1
vote
1 answer

RoutedCommand.CanExecuteChanged event not consistently firing inside ElementHost

(Background: I'm porting a WinForms app to WPF in stages. At the present time, I still have a WinForms main form with an ElementHost that has WPF content in it.) I'd like my app to be told when certain ApplicationCommands such as Cut, Copy, and…
Jeff Moser
  • 19,727
  • 6
  • 65
  • 85
1
vote
1 answer

How to fire a routed command from a specified event?

I've a simple question about commands in WPF : I have a button with an ICommand bound to the Command property, and when I click on this button, the command is started, and wow it works :) Now I whant to start a particular command when I'm just…
Antoine Blanchet
  • 325
  • 2
  • 17
1
vote
2 answers

Does calling "command.Execute" implicitly call CanExecute first?

I just implemented a call of Execute for a Command without calling CanExecute first. From debugging I would tell that CanExecute is called though; however, I'm not sure if this is coincidence. I'd like to know if I can rely on the fact that…
Em1
  • 1,077
  • 18
  • 38
1
vote
1 answer

caliburn micro: reuse existing commands

I have a simple wpf application with a Control (let's say a Button) that fires a Command (let's say ApplicationCommands.Copy). I want that same Control (the Button) to be context sensitive, that is, it performs the proper action (send the Copy…
Starnuto di topo
  • 3,215
  • 5
  • 32
  • 66
1
vote
1 answer

RegisterClassCommandBinding not firing CanExecute

In certain situations (I couldn't establish a pattern) the execution goes over System.Windows.Input.CommandManager.InvalidateRequerySuggested(); var can = GlobalCommands.UpdateWindowTitle.CanExecute(title, null); …
Amadeusz Wieczorek
  • 3,139
  • 2
  • 28
  • 32
1
vote
1 answer

Set command target to template part

1) Custom DataGrid with CommandBindings. 2) A RoutedCommand Definition. 3) A Command Target Definition. (XAML) CS : //(1) public class CustomDataGrid : DataGrid { this.CommandBindings.Add(new…
eran otzap
  • 12,293
  • 20
  • 84
  • 139
1
vote
1 answer

How can I test a RoutedUICommand?

I have an application that I am building unit tests for. For certain operations, I use ApplicationCommands (eg. ApplicationCommands.New). Is there an easy way to call CanExecute and Execute on a routed UI command in the unit test? I thought about…
travis
  • 233
  • 3
  • 11
1
vote
1 answer

Xamly begin a storyboard when a RoutedCommand is called?

Is there a way to begin a storyboard wen an ICommand is executed WITH XAML?
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
1
vote
1 answer

RoutedUICommands and currently focused element

Does a RoutedUICommand automatically reach the currently focused control (provided the control has the right command binding)? E.g.:
1
vote
2 answers

RoutedCommand in ContextMenu in UserControl

Situation: I have a static RoutedCommand defined like this: public static class Commands { public static readonly RoutedCommand GrowingOperation = new RoutedCommand("GrowingOperation", typeof(GrowingDisplay)); } In my MyUserControl.xaml I…
Stefan Over
  • 5,851
  • 2
  • 35
  • 61
1
vote
1 answer

RoutedCommands propagation strategy

I'm a newby of WPF, and 'm trying to unserstund RoutedCommands. RoutedCommands starts from command source, than event is propagated vua bubbling and tunneling. But can i stop the process? for example i would like set CanExecute = false and than stop…
stefano m
  • 4,094
  • 5
  • 28
  • 27
1
vote
1 answer

MVVM Command Routing Between Controls

I currently have a main View with a Button and a ContentPresenter which is bound to a property of the ViewModel which is another View (and associated ViewModel). Is there way to route a command from the a handler declared in the control loaded in…
jwarzech
  • 6,596
  • 11
  • 52
  • 72
1
vote
1 answer

Custom attached command

I have a situation where I want to write custom command for framework element. Which I have done like below: public class UndoRedoManager { private static FrameworkElement frameworkElement; /// ///…
James
  • 1,213
  • 2
  • 15
  • 26