RelayCommand is an implementation of the .NET ICommand interface made and described by WPF expert Josh Smith.
Questions tagged [relaycommand]
289 questions
0
votes
2 answers
Executing relaycommand in a viewmodel from a service class
I build up a custom TreeView class, with settings for each node such as "name/background" etc. I also have a ICommand property that can be set so that each node can have a custom method executed if necessary.
I build all of this in a "treeview…

Swift
- 166
- 2
- 16
0
votes
2 answers
Does ICommand always requires an object as a parameter?
When I implement the ICommand interface, the following methods are created
#region ICommand Members
public bool CanExecute(object parameter)
{
}
public event EventHandler CanExecuteChanged;
public void Execute(object…

Dave
- 8,163
- 11
- 67
- 103
0
votes
2 answers
Setting DataContext for binding RelayCommand in xaml
In the following xaml code, I'm trying bind a RelayCommand ResourceButtonClick, which is in the view model. In addition to that, I want to pass the Resource.Id as a parameter to this command.
However, ResourceButtonClick is not called. I suspect…

Brk
- 478
- 2
- 6
- 17
0
votes
2 answers
Why won't my RelayCommand fire and ObservableCollection catch selected value?
I am new to using RelayCommands (following Josh Smith's MVVMDemoApp) and could use some help identifying my mistake.
I have two listboxes. When an item in the first is selected and the "Add" button is pressed, the AddCommand is executed and the…

Rachael
- 1,965
- 4
- 29
- 55
0
votes
1 answer
Command is not acssess bind to the ViewModel - wpf
I have a Wpf DataGrid, by clicking on the delete key on the keyboard I want to call a function in my ViewModel, the DataGrid bind to a list from ViewModel. The code looks like this:
The datagrid:

Hodaya Shalom
- 4,327
- 12
- 57
- 111
0
votes
0 answers
How to tie RelayCommand to IsChecked property?
So far, I had to rely on code behind event to check or uncheck the buttons (e.g. Bold font toolbar button), and I wonder if there is a better and cleaner way to do it using RelayCommand because it is already binding to a RelayCommand for Execute and…

newman
- 6,841
- 21
- 79
- 126
0
votes
1 answer
How to access with Field Initializer and access wpf Controls
Here im having,
private ICommand AddCommand = new RCommand(p => true, p => Add() );
private void Add()
{
emp = new Employee();
DetailsEntryGrid.DataContext = emp;
EnableControls();
tBoxID.Focus();
…

sarathprasath
- 589
- 1
- 8
- 20
0
votes
1 answer
How to declare MVVM RelayCommand in viewmodel
How to use relay command in set, I use the following way, throws interface bug on set method
public RelayCommand ChartCommand
{
set
{
ChartCommand = new RelayCommand(e => ExecuteChartCommand(e));
…

charulatha krishnamoorthy
- 303
- 1
- 3
- 9
0
votes
2 answers
RelayCommand Params & Binding
View:
Playing with a basic calculator using WPF(MVVM).
I've 1 TextBox for the first num, 1 TextBox for the second num, 1 TextBlock for the results and 1 Button to execute the AddCommand and return the result.
What's the right XAML syntax to bind…

Stacked
- 6,892
- 7
- 57
- 73
0
votes
1 answer
Pass parameter to Execute and CanExecute relaycommand WPF MVVM Light
I'm trying to use Relay command from MVVMLight and I'm struggling to find the right syntax to pass the parameter to both the Execute method and also the CanExecute method.
Below is my failed attempt
NewMessageCommand = new RelayCommand

Emlyn
- 700
- 1
- 8
- 22
-1
votes
1 answer
I can't retrieve the message/text left in a textbox through a relay commands as it always returns null
This is my main body which handles the data. I invoke a command through XAML which should retrieve the data which is currently contained in the textbox in my xaml. When I try to print it or display it it doesn't work because it returns…

oknorton
- 3
- 2
-1
votes
1 answer
wpf The relayCommand needs a constractor that takes parameter
my goal is filter a dataGrid with a textbox input, so i have textbox to filter a datagrid. for all the other commands i used one of these constractors in my **relayCommand ** as follows:
// Constructors
public RelayCommand(Action

farzadwpf
- 11
- 3
-1
votes
1 answer
RelayCommand UnitTesting
How to write Unit Test case for RelayCommand when there is a parameter in Execute method.Person is model class in MVVM application.
Something like this:
DeleteThanksCommand =
new RelayCommand(param => DeleteThanks(param),…

Ashwin
- 15
- 5
-1
votes
2 answers
How can I invoke relay command with parameter programmatically wpf mvvm?
I know how to invoke relay command without parameter using mvvm pattern, but how to do the same with command with…

StalkeR
- 13
- 3
-1
votes
1 answer
Binding button to RelayCommand in Wpf MVVMLight
Hi im working on an Wpf MVVM project, but i can't figure it out how to bind a button with the Command attribute in Xaml to a RelayCommand in the Viewmodel, i found multiple answer's online but i don't get it (implementing the ICommand interface and…

J.Doe
- 37
- 10