Questions tagged [relaycommand]

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

289 questions
0
votes
1 answer

Execute RaiseCanExecuteChanged from 'subclass'

So I have the following setup: PLANNING: public class Planning : ViewModelBase { public Planning() { AddNewActivityCommand = new RelayCommand(AddActivity, CanAddActivity); } public ObservableCollection
cmircovich
  • 215
  • 3
  • 13
0
votes
2 answers

Toggle "CanExecute" of a button based on grid selection

I am very to Modern UI Programming and now i got stuck in a small C# WPF Application which is basically a learning project of MVVM design pattern. I have a DataGrid and some Buttons to handle data operation (add, edit, delete). What i want to…
CeOnSql
  • 2,615
  • 1
  • 16
  • 38
0
votes
3 answers

Using IsDirty with ICommands

I am trying to use an IsDirty flag to control CanExecute and Navigational controls during an object edit. The problem is that in order for this to work I think I have to use onPropertyChanged for my IsDirty method so that my controls get change…
ecathell
  • 1,030
  • 13
  • 25
0
votes
1 answer

Creating a command using RelayCommand with multiple tasks:

I am using RelayCommand (called CommandRelay in my code for some reason) as outlined in Josh Smith's old MVVM article. In one of my workspaces I have a textbox that takes any input and, when enter is pressed, the textbox is to be cleared, a message…
Lewis Heslop
  • 574
  • 2
  • 8
  • 25
0
votes
1 answer

System.Timers.Timer Elapsed excute command not work with RelayCommand

I am creating a custom user control which use a timer to count the time and run the command action in the view model finally. Problem When the time passed, it run the elapsed event, then execute a static command. The fact is that when I click the…
daniel
  • 1,010
  • 6
  • 15
0
votes
0 answers

MVVM Light RelayCommand.CanExecute. Can I opt out of disabling UI?

I have a windows phone 8 silverlight application and I'm using MVVM Light RelayCommands bound to the items of a LongListSelector. The RelayCommands are declared like this private RelayCommand _goToDetailsCommand; public RelayCommand…
Corcus
  • 1,070
  • 7
  • 25
0
votes
3 answers

Undo changes to Observable Collection in WPF

I'm using a observable collection in my program to store "years". User can "Add" or "Remove" years from the collection. So "years" will be listed on ListBox. Window has "OK" and "Cancel". If user click "Cancel" button after entering years, I want to…
0
votes
1 answer

Does RelayCommand, or passing an Action, behave differently when the method is from an interface?

I think this is my overall .NET inexperience speaking here, but I cannot figure out why this is happening to me. My Model ImportManys an interface called ISystemSetupEditor, and in this case I have a couple of parts that Export that interface. In…
Dave
  • 14,618
  • 13
  • 91
  • 145
0
votes
0 answers

MVVM Light Relay Command Issues

My application consists of a MainWindow and two pages which get loaded into a Frame via a simple Navigation service which uses static hard-coded Uris in the ViewModelLocator. This works fine, but I am seeing some oddities with RelayCommand. One page…
Alan Rutter
  • 321
  • 4
  • 16
0
votes
1 answer

Is it possible to set e.Handled = true in a RelayCommand?

So I've got a hyperlink that I have hooked up to the code behind like so: Xaml
JKennedy
  • 18,150
  • 17
  • 114
  • 198
0
votes
1 answer

How to find out which button I pressed?

Picture the notification-dropdown menu from Facebook. I want to implement something similar. When clicking 'Slet', it's supposed to delete that notification from the list. private void AddNotificationsToPanel(List notifications,…
0
votes
2 answers

How do you force multiple calls to RaiseCanExecuteChanged with different CommandParameters

I have a page with two buttons (I really have ten, but for example sake, lets say two), and they are both bound to a RelayCommand and each has a CommandParameter bound to two different columns from the database. Something like this,
0
votes
3 answers

RelayCommand best practice

I'm working with RelayCommands (they are in a separate class) for about a month now and I got the feeling they're kind of clunky when declaring them. Below I have 3 ways I can think of how I can declare a RelayCommand. In a first case I declare my…
Krowi
  • 1,565
  • 3
  • 20
  • 40
0
votes
0 answers

Why is parameter not being passed with Relay command

I have a user control defined in my project which contains a control to which I need a reference in my view model. To that end I am handling the loaded event of the user control in my xaml like so:
Dom Sinclair
  • 2,458
  • 1
  • 30
  • 47
0
votes
0 answers

Binding a main menu command in WPF MVVM application

I'm developing an WPF app using MVVMLight, and in my main view I have the following:
Chris J
  • 1
  • 5