Binds a RoutedCommand to the event handlers that implement the command.
Questions tagged [commandbinding]
201 questions
3
votes
1 answer
In WPF, how do I get a command in a Control Template to bind to a property in a parent?
I am relatively new to WPF and sometimes it makes my head explode. However, I do like the power behind it, especially when used with the MVVM model.
I have a ControlTemplate that contains a Button. I use that ControlTemplate inside of a custom…

Keith
- 1,119
- 2
- 12
- 23
3
votes
1 answer
How to use the CommandManager and still be able to trigger the ICommand.CanExecuteChanged event manually i.e. explicitely?
I have written myself a SingleExecutionCommand (I’m not sure about that name yet. Feel free to suggest an other, but that’s not my question), which doesn’t allow a button to be pressed again before the first execution is finished. Well, at least…

Marcel B
- 3,624
- 2
- 27
- 39
3
votes
1 answer
WPF MVVM: ICommand Binding to controls
I've totally lost in the command binding that is used in MVVM. How should I bind my object to the window and/or its command to the control to get method called on the Button Click?
Here is a CustomerViewModel class:
public class CustomerViewModel :…

Budda
- 18,015
- 33
- 124
- 206
3
votes
2 answers
Binding a static ICommand to MenuItem without a ViewModel
I am trying to bind commands to various MenuItems in a ContextMenu that I will be hooking up with a Button. But for this, I am defining all commands as static in a class that I have imported in my ResourceDictionary.
public class DesignerCanvas{
…

Agent007
- 2,720
- 3
- 20
- 24
3
votes
1 answer
CommandParameter is Nothing from ListView command binding
I am not succeeding in sending CommandParameter from ListView item. My code is below.
…

Nuts
- 2,755
- 6
- 33
- 78
3
votes
3 answers
Create view object in ViewModel
I have the following code in my C# WPF MVVM application.
public RelayCommand PolishCommand
{
get
{
polishcommand = new RelayCommand(e =>
{
PolishedWeightCalculatorViewModel model = new…

Ramesh
- 376
- 2
- 6
- 11
3
votes
2 answers
CommandBinding Ctrl + Spacebar
I handle commands inside a RoutedCommand class that implements RoutedUICommand. This would help me to block or override a command by checking their CanExecute and Execute if needed. I can override EditingCommand, ApplicationCommand, etc.. One of the…

paradisonoir
- 2,892
- 9
- 30
- 41
3
votes
1 answer
MissingMethodException when creating CommandBindings
Our program fails to open window which uses command bindings. Program works fine on dozens of computers but with one customers computers it throws MissingMethodException. Computers are with Windows 7 and .NET Framework installed.
So I made a simple…

Villeee
- 33
- 3
3
votes
1 answer
CommandBinding in ContextMenu
I have a TreeView and have created a basic TreeItem type. Each TreeItem has a header, a TreeItem Collection for children and a collection for a possible context menu. The TreeItem class has those objects:
public delegate void dExecute(TreeItem…

Jan
- 2,168
- 2
- 19
- 28
3
votes
1 answer
How to add a command to a xamdatagrid cellactivated event without breaking MVVM
i am using a XamDataGrid to display my data. Now I want to add different commands to each column.
Using the CellActivated event on the whole grid and then binding to ActiveCell wont work since the Viewmodel would have to know about the View and how…

mtxviper
- 101
- 2
- 8
3
votes
3 answers
MVVM View event Viewmodel command binding
I'm looking for a good (read: simple) example on how to implement event aggregators with Prism. I've never used Prism and I'm also quite new to MVVM itself.
I have a WPF canvas as a View and I want to handle the MouseUp event on the canvas in the…

user823486
- 139
- 3
- 9
2
votes
1 answer
how to add multiple command bindings in wpf
I am working with WPF. I want to create keyboard shortcuts for my WPF application. I have created as following. The first command binding tag for "open" is working and command binding for exit is not working. I dont know what is the…

havan
- 79
- 2
- 13
2
votes
2 answers
Issue with putting Command CanExecute and Executed handlers out of the main window class
Basically I've got a command binding for the command itself assigned to Window.CommandBindings:

Johnny
- 889
- 2
- 13
- 24
2
votes
3 answers
WPF CommandBindings defined in one window not available in another
I have this problems where I have all these CommandBindings defined in the MainWindow, and said commands are available within that window to be used in any Button or MenuItem. The problem is that if in other windows the command binding is not…

Carlo
- 25,602
- 32
- 128
- 176
2
votes
1 answer
WPF - CommandBinding to a Command defined in a F# library doesn't work
The repo https://github.com/francotiveron/WpfApp1 contains the following projects:
A C# WPF library (WpfLibrary1)
net6.0-windows
…

Franco Tiveron
- 2,364
- 18
- 34