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

ListView.SelectionChanged to RoutedCommand

I'm working in the MVVM design pattern with WPF. I have a ContextMenu with several items in it on a ListView. Based on the number of items selected in the ListView, I want to enable/disable certain MenuItems. Is there a way to route the…
Flacmonster
  • 11
  • 1
  • 3
1
vote
1 answer

How do I get input bindings which would trigger routed command?

I have a menuitem which have a command assigned to it (MyCommands.Indent) and two text areas, both having an input binding triggering MyCommands.Indent. The hard part is that input bindings have different gestures and I would like these gestures to…
Sergej Andrejev
  • 9,091
  • 11
  • 71
  • 108
0
votes
1 answer

Need work-around for overriding RoutedUICommand.Text property

I have a static Command class like this (but with many more commands): class GuiCommands { static GuiCommands() { addInterface = new RoutedUICommand(DictTable.getInst().getText("gui.addInterface"), "addInterface",…
JCH2k
  • 3,361
  • 32
  • 25
0
votes
1 answer

Listening to routed events / commands from a popup

I have a control that dynamically creates a popup. The popup contains controls that fire routed events / commands, which I want to react to in the original control. The original control is set as the placement target of the popup. Would you expect…
GazTheDestroyer
  • 20,722
  • 9
  • 70
  • 103
0
votes
2 answers

Log events on RelayCommand vs RoutedCommand

I have the following problem: I need to be able to log commands bound to the buttons in my code. The system that I am working on has all it's buttons as RelayCommand. I have found a website that explains how to do this, but with RoutedCommands. The…
Defi
  • 3
  • 5
0
votes
1 answer

How do you Execute a Silverlight ICommand?

This is such a basic question, but I have to ask. In SL, I have this XAML:
0
votes
1 answer

Cache CanExecute (or anything) in WPF?

The Cache object in System.Web is pretty freaking nice. I handle my CommandBinding.CanExecute sort of like this: CommandBindings[0].CanExecute += (s, e) => { e.CanExecute = NotInsignificantRoutine(); }; In my scenario, the return value of…
Jerry Nixon
  • 31,313
  • 14
  • 117
  • 233
0
votes
0 answers

WPF .net 5 application with DI: accessing services from RoutedCommand in a UserControl

I've got a UserControl in a WPF application which has a RoutedCommand. The RoutedCommand needs to access a service that I've registered in the DI container. The problem is that I can't figure out how to get a reference to the service so the…
Angelo
  • 2,936
  • 5
  • 29
  • 44
0
votes
1 answer

In wpf, can an adorner catch a routed command?

I have a listboxitem, which when clicked, produces an adorner holding a custom control made of a textbox label and a MediaElement. All is well and the selected movie plays. The listbox was subclassed into a custom control as "ChartCanvas". My…
Alan Wayne
  • 5,122
  • 10
  • 52
  • 95
0
votes
1 answer

WPF VB.net - Can multiple CommandBindings be executed for the same command?

In WPF I'm trying to use commands to set all the content in multiple textboxes at once. The following code is able to get a command on the toggle button to execute for which ever textbox has scope but I can't seem to get the command to execute for…
Greg Bouz
  • 13
  • 4
0
votes
4 answers

How to bind commands with a view model?

I've read a number of posts on binding and commands but I am struggling to get what I want working. The below works fine public partial class TailoredReading : Window { public static RoutedUICommand myRoutingCommand = new…
0
votes
1 answer

WPF MVVM - global command with parameters

I need to open same window for displaying reports, from many different pages, on button click. But (based on page where I open It) I need to provide which report should be displayed, title of window etc. So I'm trying to create a global command…
Lucy82
  • 654
  • 2
  • 12
  • 32
0
votes
1 answer

using routed events within Silverlight user controls

within my current project file I have a user control that has a storyboard animation applied to the control. When a button is clicked in the page the storyboard starts and basically visually presents the control to the user. The storyboard resides…
rlcrews
  • 3,482
  • 19
  • 66
  • 116
0
votes
1 answer

Execute a method on second control from the first control in WPF

My ViewControl has a method called ZoomIn(). How can I execute this method on the ViewControl by clicking a Button control without going to the code-behind?
Vahid
  • 5,144
  • 13
  • 70
  • 146
0
votes
1 answer

How to set ButtonBaseExtensions.Command DataContext, and not change the buttons' context

I am using mvvm light in a WP7 app. I have a listbox with an itemsource of a collection of objects. The ItemTemplate DataTemplate for the listbox contains a button. The button contains a textblock that displayes a property from the bound object.…
Roger
  • 2,063
  • 4
  • 32
  • 65