RelayCommand is an implementation of the .NET ICommand interface made and described by WPF expert Josh Smith.
Questions tagged [relaycommand]
289 questions
3
votes
0 answers
How i can solve COMException at the relaycommand? Do I miss something?
I have a UWP WinRt App.
I use MVVM Light.
I have a ListView on the MainPage. When I press on a Item with A x:Bind RelayCommand i go to a DetailsView of the Item. If I debug on a Lumia 635 I got an Error after pressing on a Item three times.
=> I…

TobiasB
- 161
- 1
- 10
3
votes
1 answer
getting the name of header in treeviewItems
I have created a treeview and now I want to get the name of the header as a string to use in the ViewModel. The command works but I can't get the name of the header to pass as a parameter in the method.
How do I get the name of the header each time…

Phil
- 561
- 2
- 16
- 29
3
votes
2 answers
MVVM light RelayCommand triggers twice
I'm working on a new c# MVVM light modern ui WPF application and I ran into some weird trigger behavior. So to describe the situation, here is the following:
I have an XML view with triggers. (Loaded method as example)
…

RolandMakkelie
- 355
- 3
- 14
3
votes
1 answer
How do you send in the LayoutRoot into a RelayCommand via a EventToCommand?
Grid example with the trigger:

user298145
- 43
- 4
3
votes
1 answer
How to prevent CommandManager from invoking CanExecute whenever there is UI interaction?
Our UI currently has a lot of controls that are bound to commands with some complex CanExecutes. The problem we are facing is that whenever CommandManager determines that the UI needs to be re-evaulated, all commands run their CanExecute, which in…

d.moncada
- 16,900
- 5
- 53
- 82
3
votes
1 answer
ICommand - RelayCommand CanExecute method does not update button IsEnabled property
I have the following implementation of an RelayCommand in my viewModel:
RelayCommand _resetCounter;
private void ResetCounterExecute()
{
_data.ResetCounter();
}
private bool CanResetCounterExecute()
{
if (_data.Counter > 0)
{
…

ck84vi
- 1,556
- 7
- 27
- 49
3
votes
2 answers
WPF relaycommand from usercontrol
I'm new to WPF and in the spirit of trying to do things the correct way have tried to implement MVVM in my application. I've made use of the frequently mentioned article by Josh Smith, and apart from making me realise how little I know, it has left…

pilsdumps
- 495
- 1
- 7
- 23
3
votes
3 answers
Pass selected item as command parameter vs. using a bound ViewModel Object (MVVM)
Hopefully this is a simple MVVM question, but I'm trying to grasp command parameters.
I have a user select an item from the ListBox, and click "Delete Selected". The ListBox binds SelectedItem to "SelectedTemplate". My button XAML looks like…

chickenricekid
- 390
- 4
- 19
3
votes
1 answer
RelayCommand with Argument throwing MethodAccessException
I am creating an application using .Net and MVVM Light and I am having some trouble for RelayCommands.
I'm trying to create a RelayCommand which takes in a single argument and passes it to a function within the same ViewModel. However everytime I…

user2898150
- 33
- 2
3
votes
2 answers
RelayCommand not firing on some computers
First of all, this is my first post on SO, so be gentle ;)
I have a very simple WPF application with a menu with two options and some buttons in different Views, most of these have data bindings to a Microsoft.TeamFoundation.MVVM.RelayCommand. When…

moggizx
- 476
- 1
- 5
- 19
2
votes
2 answers
Passing Command Parameters
I'm trying to pass a command parameter with my command. I have commands in general working but passing a parameter doesn't seem to be going to well for me.
I'm trying to pass the UserName Property from the Hierarchical Data in my XAML. What am I…

rreeves
- 2,408
- 6
- 39
- 53
2
votes
1 answer
How does WPF determine when to Invalidate using the CommandManager (CommandManager.InvalidateRequerySuggested)?
I've been using the RelayCommand a bit here and there, and it got me to wonder and want to know... when exactly does the CommandManager.InvalidateRequerySuggested() get called by WPF?
My guess is every time any other routed event on UI get's…

myermian
- 31,823
- 24
- 123
- 215
2
votes
1 answer
How or when to cleanup RelayCommand objects in WPF/MVVM?
I am using the standard Josh Smith implementation of RelayCommand to implement ICommands in my WPF/MVVM application. See: WPF Apps with the MVVM Design Pattern
A few of my CanExecute methods take a long time to run. Individually, they aren't bad (a…

Paul Chavez
- 895
- 2
- 13
- 22
2
votes
1 answer
MVVM Relay Command does not fire in Silverlight RIA app
I am developing a Silverlight 4 RIA (Entity framework) application and I am having issues using a MVVMLight RelayCommand. I have used them before without problem but there seems to be an issue after I have implemented the ViewModelLocator…

Phil Murray
- 6,396
- 9
- 45
- 95
2
votes
2 answers
Why does RelayCommand.Execute take an object instead of a T?
This hasn't done anything but cause the need for what would otherwise be unnecessary casting (or rather, caused me to pull down the codebase and make the change myself). Is there a reason for doing this?
References:
Source on Codeplex
Blog posting…

michael.bartnett
- 787
- 7
- 20