Questions tagged [relaycommand]

RelayCommand is an implementation of the .NET ICommand interface made and described by WPF expert Josh Smith.

289 questions
1
vote
2 answers

RelayCommand commandParameter is null

I have a button on my usercontrol
kzub
  • 232
  • 3
  • 13
1
vote
1 answer

Where to call RaiseCanExecuteChanged?

I'm working with MVVM Light Toolkit, and I'd like to create a RelayCommand. If my ViewModel has some String properties, which ones call the RaiseCanExecuteChanged in the setters, everything works fine, the command can be executed when I want. But if…
Aaaaaaaa
  • 2,015
  • 3
  • 22
  • 40
1
vote
1 answer

Preventing almost duplicate RelayCommands in MVVM/MDI app

I'm using an MDI solution (see http://wpfmdi.codeplex.com/) and MVVM. I use one RelayCommand to bind the toolbar and/or menu to the Main ViewModel, like: ICommand _editSelectedItemCommand; public ICommand EditSelectedItemCommand { …
Michel Keijzers
  • 15,025
  • 28
  • 93
  • 119
1
vote
2 answers

Binding generic type through MVVM Light RelayCommand

I am using Implicit Data Templates which are applied to the items of an ItemsControl:
Seb Boulet
  • 981
  • 6
  • 18
1
vote
1 answer

Control Template event with Relay Command

I've got problem triggering events in a control template which is in another control template and using MVVM light relay command. Here is the case: main_control is templated in a generic.xaml style. sub_control is templated the same…
1
vote
1 answer

.Net MVVM RelayCommand not binding to custom view's Bindable Property

For some context, I'm using Microsoft's MVVM Toolkit and .Net Maui. Im trying to bind a RelayCommand to a Command Bindable object of a view. The code builds fine, it's at runtime that I'm seeing the following error: "Warning: 'DeleteCommand'…
Eliezer Ferrá
  • 127
  • 1
  • 12
1
vote
1 answer

WebView Navigated Event .NET MAUI using CommunityToolkit.MVVM and EventToCommand

I am using [RelayCommand] for handling the navigated event of WebView in .NET MAUI. async void Navigated(WebNavigatedEventArgs args) I have bound it in my XAML, using
1
vote
0 answers

Full RelayCommand in F#?

I am new to F#. As a learning experiment, I am rewriting a C# application in pure F#. How can the "RelayCommand" , RelayCommand, of C# be written in F# ? Any help is most appreciated. TIA As requested, this is the RelayCommand I've been using in C#.…
Alan Wayne
  • 5,122
  • 10
  • 52
  • 95
1
vote
3 answers

Resetting SelectedItem on a Listbox bound to a RelayCommand on a ViewModel

Using the EventToCommand behaviour that comes with MVVM Light I am binding the SelectedItem of a ListBox to a RelayCommand on a ViewModel All works great in my Windows Phone 7 app except that after navigating away from the View with the ListBox then…
1
vote
1 answer

Bind a WPF RelayCommand from DataTemplate to a Button inside a UserControl

I searched quite a while to solve this issue with RelayCommands but could not find a similar solution. The issue is that I have a UserControl, and in this UserConrol is a button among others (btcNotKnown towards the end of the code):
Patrick
  • 96
  • 1
  • 8
1
vote
1 answer

Showing another View from my current Viewmodel and closing a view from my viewmodel?

I have another view setup and ready and waiting with its viewmodel. My RelayCommand arrives in my "Current" viewmodel. What is the best way to show the new view from my current viewmodel? I have been reading and it appears that I need to use the…
Martin
  • 23,844
  • 55
  • 201
  • 327
1
vote
1 answer

MVVM Light, use RelayCommand with Methods returning data

I'm experimenting with MVVM Light for an application which acquires data from sensors. The sensor model exposes properties and methods. Some of these methods take arguments and return data. Example, public double GetVelocity(int AxisNo) { Do…
Mandeep Singh
  • 91
  • 1
  • 12
1
vote
1 answer

Calling CommandManager.InvalidateRequerySuggested in ViewModelBase?

Initial problem: I'm using the typical RelayCommand implementation in my MVVM Application. I realized that the CanExecute of my RelayCommand is not always called even if meaningful properties of my ViewModel have changed. I read that we can manually…
Spirielle
  • 23
  • 1
  • 3
1
vote
1 answer

Unit test MVVM Light Messenger message is sent when a RelayCommand is executed

How do I unit test that the messenger send was called when a RelayCommand is executed? ViewModelClass: public class MyViewModel { public MyViewModel() { this.MyCommand = new RelayCommand(() => SendMyMessage()); } public int Id {…
empo
  • 1,133
  • 5
  • 21
  • 41
1
vote
2 answers

What is the best way to handel click-events in MVVM?

What is the best way to handel click-events in MVVM? Are there a best way? I have found two solutions: with a relaycommand: RelayCommand buttonAddCategory_Click; public ICommand ButtonAddCategory_Click { get { return…
jwillmer
  • 3,570
  • 5
  • 37
  • 73