Binds a RoutedCommand to the event handlers that implement the command.
Questions tagged [commandbinding]
201 questions
7
votes
1 answer
Use and in UWP 10 app
How can I use and in a Windows 10 universal app? I will get something like this with Blend:
Source both images above: Jef Daels 2015
In may (bad) documentation, I've read that it must be something…

H. Pauwelyn
- 13,575
- 26
- 81
- 144
7
votes
1 answer
Using a WPF controls own properties in Command Binding
I have a ToggleButton. I'm using a command binding, and I want to pass the value of its IsChecked property as a parameter. How can I do this without naming the ToggleButton and using its name to address itself?
Currently I'm solving this by naming…

stiank81
- 25,418
- 43
- 131
- 202
6
votes
1 answer
Is there a difference between adding CommandBindings to a control vs using RegisterClassCommandBinding?
Previously I had been using
this.CommandBindings.Add(
new CommandBinding(ApplicationCommands.Copy, this.cmdCopy_Executed, this.cmdCopy_CanExecute))
where cmdCopy_Executed is a non-static function, but I've seen folks using
static MyControl()
…

tofutim
- 22,664
- 20
- 87
- 148
6
votes
1 answer
Does Treeview use command bindings for expand/collapse?
The WPF Treeview responds to + and - keystrokes to expand and collapse nodes in the tree. Great!
Is there an existing command I can bind my toolbar buttons or menu items to to perform the same actions in the treeview? I don't see anything related…

dthorpe
- 35,318
- 5
- 75
- 119
6
votes
4 answers
How to use the text of a routed command as button content
I have a button on a view that is bound via a RoutedUICommand to a command defined in the ViewModel.
The XAML code excerpt from the view:
In the View's CodeBehind I add the command binding from…

PVitt
- 11,500
- 5
- 51
- 85
6
votes
1 answer
Command Binding Memory Leak in WPF
When i create a user control that has a CommandBinding to a RoutedUICommand im worried that i get memory leaks.
scenario:
Have a RoutedUICommand as a static in c class where i store my commands
Implement the CommandBindings on a user control.
Add…

Aran Mulholland
- 23,555
- 29
- 141
- 228
6
votes
1 answer
WP8 - access datacontext of parent
How can I access the datacontext of the parent element in windows phone 8?
AncestorType is not available in WP8.
…

user1288039
- 99
- 1
- 7
5
votes
1 answer
Control does not refresh after CanExecute-Result does change
in my window I have buttons for load and save methods. I use CommandBinding and the save-button has a CanExecute property to keep the user from saving the data before it is loaded.
The CanExecute-Methode is connected to a simple bool value called…

TalkingCode
- 13,407
- 27
- 102
- 147
5
votes
2 answers
WPF: Trouble controlling a button's enabled/disabled state using Command binding and a thread
I have a WPF app that simply contains a Button and a Textbox to display some output. When the user clicks the Button, a thread starts which disables the Button, prints stuff to the output Textbox, then the thread stops (at which point I want the…

Tam Bui
- 51
- 1
- 2
5
votes
2 answers
WPF listbox with contextmenu canexecute not called until something selected
I have a ListBox the ItemTemplate bound to an ObservableCollection of my items.
At the moment, I'm trying to implement Cut/Copy/Paste/SelectAll (To keep it short, I'll just show selectall here...)

DanW
- 1,976
- 18
- 14
5
votes
2 answers
WPF CommandParameter Binding Problem
I'm having some trouble understanding how command parameter binding works.
When I create an instance of the widget class before the call to InitializeComponent it seems to work fine. Modifications to the parameter(Widget) in the ExecuteCommand…

user22522
- 121
- 1
- 1
- 2
5
votes
2 answers
MVVM Command Binding
I'm trying to learn the MVVM pattern. The main problem I'm having is learning where I should be declaring, creating and binding command objects.
2 examples:
I have a main form that acts like a switch board or main menu. Selct button 1 and View 1…

thrag
- 1,536
- 4
- 20
- 32
4
votes
1 answer
GalaSoft MvvmLight RelayCommand stops working when accessing closure
I struggle using the GalaSoft.MvvmLight.RelayCommand. All is working fine until i try to Access a closure. I don't get any error or log output.
This Code is working:
for (int i = 0; i < 3; i++)
{
var iTemp = i;
…

Jan Schweda
- 41
- 4
4
votes
2 answers
WPF: Trigger RoutedCommands implemented in UserControl nested inside a ContentControl
How can I trigger routed commands implemented inside a UserControl which is nested inside a ContentControl?
What I basically have is an outer view (derived from UserControl) which contains:
1) A button which should trigger the command MyCommand:
The…

devar
- 95
- 8
4
votes
1 answer
WPF Two Commands handlers, One Command
Im deriving from a third party control. It is implementing ApplicationCommands.SelectAll. However the behaviour i want is slightly different. there is no virtual method i can override, and when i register a class handler, like so
…

Aran Mulholland
- 23,555
- 29
- 141
- 228