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

Correct way to handle commands that rely on multiple view models

I'm relatively new to WPF and MVVM and i am trying to understand how to use commands correctly when they have dependencies in more than 1 view model. A couple of examples: In my current application i have a RelayCommand which causes a save action…
DaeDaLuS_015
  • 110
  • 5
0
votes
2 answers

How to run methods across pages in Silverlight?

I need to be able to set the visibility of the Border to be visible for 10 seconds. The border resides in MainPage.xaml which is parent to Content.xaml. The trick is that I need to change the visibility of the border by clicking ContextMenu item…
vladc77
  • 1,064
  • 3
  • 22
  • 47
0
votes
1 answer

WPF contentcontrol routedevent resource file list for event

so I have a contentcontrol that has a routedevent: public class TestBlind : ContentControl { public static readonly RoutedEvent VisibilityVisibleEvent = EventManager.RegisterRoutedEvent("VisibilityVisible", RoutingStrategy.Tunnel,…
Jon
  • 15,110
  • 28
  • 92
  • 132
0
votes
2 answers

Clear MenuItem, with clear command

hi i'm a "very" beginner in wpf i'm trying to make a menu item "Clear", it should clear the text in the focused text box, actually i could not find a built in command that does the job like (copy,paste,cut..etc) is there one built in or do i have…
user452799
  • 73
  • 6
0
votes
2 answers

contextsensitive RoutedUICommand.CanExecute, Execute

I have a single RoutedUICommand that can be accessed through various places in the UI. Such as global Keyboardshortcut, Menu, ContextMenu or Button. The code that is to be executed in the RoutedUICommand.CanExecute and RoutedUICommand.Execute…
bitbonk
  • 48,890
  • 37
  • 186
  • 278
0
votes
2 answers

Prevent button command from executing from OnClick when a condition is met

I have a RoutedUI Command that is bound as a Command property for a button and an OnClick event. Whenever I evaluate some condition from the OnClick I want to prevent the command from executing. I referred to this post but dosen't help much Prevent…
nikhil
  • 1,578
  • 3
  • 23
  • 52
0
votes
1 answer

How can I make RoutedUICommand.OnCanExecute for a command assigned to a button depend on Keyboard.FocusedElement?

I have a question regarding RoutedUICommand.OnCanExecute and Keyboard.FocusedElement. I 've created a command with an InputGesture (keyboard short-cut), assigned it to a MenuItem or Button and added it to the owning window's CommandBindings with…
mike
  • 1,627
  • 1
  • 14
  • 37
0
votes
1 answer

WPF command binding not working

I want to do a command binding in my WPF project: 1) I created the following module Namespace Test Module CustomCommands Public ReadOnly Export As RoutedUICommand = New RoutedUICommand( "Export", "Export", …
bluefox
  • 175
  • 3
  • 16
0
votes
1 answer

What is the ownerType of RoutedUICommand

I am trying to understand the constructor parameters of RoutedUICommand. What is the ownerType argument for? Is it a valid solution to just pass null or typeof(object) as ownerType? What is the value of ownerType, when calling the empty…
ˈvɔlə
  • 9,204
  • 10
  • 63
  • 89
0
votes
0 answers

How to set CommandTarget on RoutedUICommand, executed via KeyGesture?

On every ICommandSource you can set the CommandTarget Property. In the case of RoutedUICommands it means, that this Target will be used instead of the KeyBoard.FocusedElement. So for Example take this Command: public static class MyCommands { …
LuckyLikey
  • 3,504
  • 1
  • 31
  • 54
0
votes
1 answer

WPF RoutedCommand/RoutedEvent who/what raises the event?

I'm trying to understand how WPF implements the routed commands which, internally, are themselves implemented by routed events. In the UIElement class definition, we find this piece of code: EventManager.RegisterClassHandler(type,…
Quoc-Minh
  • 113
  • 3
  • 9
0
votes
2 answers

Firing and Capturing of Custom RoutedCommands within CustomControls for MenuItems

WPF. .NET 4.6 I'm trying to learn RoutedCommands. In the below code, my desire is to have my custom class of MenuItem respond to the user click by firing a custom routedcommand which is listened to by the parent menuitem. When the parent menuitem…
Alan Wayne
  • 5,122
  • 10
  • 52
  • 95
0
votes
1 answer

How to bind a CustomControl to a CustomCommand?

WPF .NET 4.6 In the below code, clicking on the menu item will activate the command and correctly display: "InkAndGesture command executed" It is my understanding that the RoutedUICommand will travel up and down the visual tree. So how can the…
Alan Wayne
  • 5,122
  • 10
  • 52
  • 95
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
0 answers

WPF AlignCenter command Key Gesture (Ctrl + E) doesn't work

The title explains it all. According to official, up to date documentation from MS, this command's default key gesture is Ctrl + E, however, it doesn't work. The command works in my app like a charm, except it doesn't accept the gesture, which is…
Krepsy 3
  • 63
  • 1
  • 2
  • 11