RelayCommand is an implementation of the .NET ICommand interface made and described by WPF expert Josh Smith.
Questions tagged [relaycommand]
289 questions
1
vote
1 answer
Where to write Relay Command?
I am trying to follow standard MSDN steps to form up MVVM architecture in WPF. My folders and class hierarchy are as below.
Models
=> FormModel.cs
ViewModels
=> MainViewModel.cs
=> ViewModelBase.cs
Views
=> MainView.xaml
and
=>…

Pratik Shah
- 89
- 3
- 10
1
vote
2 answers
CanExecute on Relay Command not working
I have a simple program with a button which is binded to a Relaycommand in View model as below.I am setting the CanExecute to true based on some value (set by a timer you can find details below).My button is enabled when Status is 3,initially as I…

TRS
- 1,947
- 4
- 26
- 49
1
vote
2 answers
How can I pass a function with one parameter to an ICommand?
Here's my ICommand:
public ICommand ConfirmLotSavedCommand {
get
{
return new RelayCommand(ConfirmLotSaved);
}
}
The problem is I have deserialized data that I want to store into database after a user clicks…

Kala J
- 2,040
- 4
- 45
- 85
1
vote
2 answers
reuse code for RelayCommand
I'm using MVVM light for a WPF application. I have a view model with several commands that use the RelayCommand. Since the code is very similar for each command, I created a GetCommand Method. But the resulting RelayCommand does not work if I use…

Kuepper
- 992
- 13
- 39
1
vote
2 answers
Freeze selection of ListBox items when a selection is already made
I need to be able to "Freeze" a Listbox selection until I clear the User's selection of an item.
I can't seem to find any examples and need a little pointer in the right direction.
I'm in MVVM so I'll probably want to fire a RelayCommand and only…

Rachael
- 1,965
- 4
- 29
- 55
1
vote
1 answer
populating data to second combo box on first combo box selection change in wpf application
I am developing a wpf application. here i have to populate 2nd combo box based on the first combo box selection.
my xaml as follows:
…

SNS
- 395
- 4
- 8
- 19
1
vote
2 answers
.NET delegate equality?
I think this is the question, anyway. I am using a RelayCommand, which decorates an ICommand with two delegates. One is Predicate for the _canExecute and the other is Action for the _execute method.
---Background motivation --
The motivation has to…

Berryl
- 12,471
- 22
- 98
- 182
1
vote
1 answer
Delegates and RelayCommand
I thought I'd got my head around delegates, in that it creates a reference to a method and then can be referenced by 'external' code (another dll/project).
Now I'm using MVVM and I see this thing called RelayCommand which appears as if it is…

Dave
- 8,163
- 11
- 67
- 103
1
vote
1 answer
MenuItem Visibility binding to RelayCommand CanExecute with Parameter
I'm using Josh Smith RelayCommand class in a WPF MVVM app for creating my commands inside my ViewModel:
For example:
ICommand RemoveAllCommand = new RelayCommand

Adolfo Perez
- 2,834
- 4
- 41
- 61
1
vote
1 answer
Global KeyBinding to command in the active view's Viewmodel
I have this in MainWindow.xaml:
I have several…

l33t
- 18,692
- 16
- 103
- 180
1
vote
2 answers
How to get the sender of the InputBinding-Command
I have this xaml code:
and that's the Code in my ViewModel:
private RelayCommand _keyEnterCommand;
public ICommand…

David
- 4,027
- 10
- 50
- 102
1
vote
1 answer
How to change a three steps operation into a command in WPF?
I'm learning MVVM design pattern so I'm trying to change some operation into Command.
Here's an example, MainWindow has a Canvas as the container, and the user can draw rectangle through dragging. So I write the code as below
protected override…

Cuero
- 1,169
- 4
- 21
- 42
1
vote
1 answer
Proper way in MVVM to direct the handling of a RelayCommand to a view model parent
I'm very new to MVVM and even WPF to some degree so bear with me...
I've got a MVVM application that has a main window, containing a viewmodel instance of different types depending on application state. One of these viewmodels is an options screen…

Firoso
- 6,647
- 10
- 45
- 91
1
vote
2 answers
Binding BindableApplicationBarIconButton IsEnabled property to Relaycommand CanExecute Windows Phone 7.1
I am using Phone7.Fx R1
The following works. The system does not react when a user presses the button. This means, than there is no reaction if Stop Game is pressed without a game has been started and vice versa.
However the button looks active. I…

Casper Thule Hansen
- 1,510
- 2
- 19
- 36
0
votes
1 answer
Binding a RelayCommand AND an additional condition
I am trying to bind a RelayCommand's CanExecute in my main window to a child window that possibly does not exist. How should I do it?
Currently I have: