Questions tagged [relaycommand]

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

289 questions
1
vote
0 answers

Change combobox values based on a button click c# wpf

I'm trying to transition from WinForm to WPF, and while studying this topic i came across this challenge, change combobox items upon a button click and create a button that shows the original selected value" I managed to do this with inline…
styx
  • 1,852
  • 1
  • 11
  • 22
1
vote
2 answers

Code after 'await Task.Delay(5000)' is not executing until the execution of relaycommand is completed

In my WPF application, i am calling relaycommand private void AutoRun(object parameter) { for(int i=0;i<10;i++) { MoveLotCommand.Execute(0); } } which inturns call another relay command private void…
amandeep
  • 19
  • 3
1
vote
1 answer

Execute a method in another Control using MVVM

I have built a dummy UserControl that has a method in its code-behind to display a message. I have used this control in my main window and want to execute its method when I click a Button using Commands and MVVM. Is this a good design, and if not,…
Vahid
  • 5,144
  • 13
  • 70
  • 146
1
vote
1 answer

relaycommand pass parameter wpf

All I want to do is pass a parameter from xaml into a viewmodel. The CanExecuteChanged event is not firing for my command in order to enable a button which performs an operation. I have no problem executing this logic if no parameter is passed into…
1
vote
1 answer

Odd behaviour onCanExecute RelayCommand MVVMLight 5+

I'm migrating a tool from MVVM Light 4.0.3 to 5.4.1 and I have found a very odd issue with the newest RelayCommand implementation. This is the old implementation in the V4.0.3: This is the newest implementation in the V5.4.1: Before I was able…
Federico Navarrete
  • 3,069
  • 5
  • 41
  • 76
1
vote
1 answer

How to pass selected TreeView item to the RelayCommand without code behind

I have a TreeView filled with items of my custom type ToolbarTreeItem. Now when the user clicks on an item, I want to know which item was clicked in the MainViewModel. I want to achieve this without code behind, but with a RelayCommand. So how do I…
RUL
  • 268
  • 2
  • 12
1
vote
1 answer

RelayCommand change canExecute automatic

The current step of learning MVVM is RelayCommand for me. So i came up with this RelayCommand class: Relay Command class public class RelayCommand : ICommand { private readonly Action _execute; private readonly Func
Pielroja
  • 35
  • 6
1
vote
2 answers

UI Validation before executing RelayCommand WPF

I'm new to WPF and I tried to implement a demo application with RelayCommand. My question is this: If i want to execute a command which has to ask the user if he's sure he wants to execute it first - what's the best way to do it? I need an "are you…
Horse Pen
  • 547
  • 1
  • 5
  • 8
1
vote
1 answer

MVVMLight RelayCommand.RaiseCanExecuteChanged don't raise the CanExecuteChanged event

I'm developing an application in WPF, with MVVMLight framework. I'm trying to make unit tests (i'm novice in that). So I try to simulate my view by subscribing to the CanExecuteChanged event on my command and verify that it is correctly called. But…
Corabox
  • 157
  • 10
1
vote
2 answers

RelayCommand for a button in other window

I have a mainwindow, and another window called Loginwindow. In some point this LoginWindow will shows up to get some login info... In the LoginWindow I have a button and it's Command property is binding to OkCommand in the MainViewModel like…
1
vote
1 answer

How do I check if all textboxes inside ItemsControl are valid

I have this template for an itemscontrol:
Talha Talip Açıkgöz
  • 1,821
  • 4
  • 15
  • 28
1
vote
1 answer

How do I add item to a list when I select the item from a listview and click add button in the UI on WPF

I'm a newbie so excuse my question if it's too fade or if it's unclear. any way, In my UI (WPF), i have a ListView that i created containing an observable collection of Type Collection = new ObservableCollection and i have two Buttons "Add" &…
AMI
  • 97
  • 12
1
vote
1 answer

WPF MVVM RelayCommand multiple buttons on each DataGrid row, set enabled/disabled button state for selected row only

WPF MVVM RelayCommands DataGrid with multiple buttons on each row. Goal: To enable and disable some of the buttons for the selected row only, when I click on my "Start" button Current Behavior: When I click the Start button, the buttons get…
1
vote
2 answers

WPF MVVM RelayCommand Action, canExecute, parameter

I´m using MVVM, I have defined a Command in a button. I want to use in this Command a parameter, execute an action and proving if Canexecute. I have this RelayCommand class RelayCommand : ICommand { private readonly Action
user1253414
  • 249
  • 1
  • 8
  • 17
1
vote
0 answers

RelayCommand works in C# but not in VB if not created in the constructor of the ViewModel

I tried to implement button click command using mvvmlight relaycommand as described on this msdn page. Basically first I implemented in VB and C# as below. As you can see codes are almost same but button click doesnt work in VB unless I create the…
Emil
  • 6,411
  • 7
  • 62
  • 112