Questions tagged [canexecute]
66 questions
2
votes
1 answer
WPF MVVM CanExecute method implementation problem
I am trying to implement a WPF MVVM application. And I am a beginner in this platform. All I need is to implement a CanExecute method for my SaveCommand
Here is the code
WPF XML Code

Taufiq Abdur Rahman
- 1,348
- 4
- 24
- 44
2
votes
3 answers
Button using ICommand does not get disabled?
I have a button control in my wpf-mvvm application.
I use an ICommand property (defined in viewmodel) to bind the button click event to viewmodel.
I have -> execute and canexecute parameters for my ICommand implementation (RelayCommand).
Even if…

Relativity
- 6,690
- 22
- 78
- 128
2
votes
2 answers
Relaycommand ICommand.CanExecute not firing
i have the following problem:
I have a relaycommand with a execute an a canexecute method, but everytime i call raisecanexecutechanged(); it calls raisecanexecutechanged in relaycommand, sets a new delegate for it and then returns back to the view…

Revooo96
- 31
- 6
2
votes
1 answer
Update CanExecute from another ViewModel's actions
Where do I run my CreateBestPriceListCanExecute method in order to update my CanExecute in the below code snippet?
class BestPriceViewModel : ViewModelBase
{
ObservableCollection bestPriceList = new…

Mike
- 850
- 10
- 33
2
votes
1 answer
Weird behavior of canExecute in Mvvmlight RelayCommand
I'm learning Mvvmlight,and quite confused about its canExecute of RelayCommand.
Basically,I have a Button and a PasswordBox in the view,and a Command in the viewModel.What I want is to disable the Button if the PasswordBox is empty.My solution is to…

Chenxiao
- 373
- 1
- 3
- 15
2
votes
1 answer
File.canExecute() says every file is executable?
I am using this code to test it;
public class CanExecuteTest {
public static void main (String[] args) {
File currentDir = new File(System.getProperty("user.dir"));
traverse(currentDir);
}
public static void…

yasar
- 13,158
- 28
- 95
- 160
2
votes
1 answer
CanExecute WPF command on field change
What I want to do is fairly simple however I have not seen examples online with respect on how to do it. I want an 'Update' button to become enabled if a field has been changed.
Context: I have a WPF form which updates a row in a database. I do not…

Duvarian
- 177
- 3
- 10
2
votes
1 answer
relaycommand CanExecute returns incorrect value
I create a pretty standard MVVM Light RelayCommand, with the canExecute parameter being:
() => (customer.Regions.Count > 0)
when necessary I call RaiseCanExecuteChanged(); and the canExecute is not reevaluated correctly. I then also call it…

user1151923
- 1,853
- 6
- 28
- 44
1
vote
1 answer
How to unit test CanExecuteChanged and RaisePropertyChanged
I am trying to practice strict TDD and have run into issue related to DelegateCommands and testing that CanExecute has been called.
These are my two test titles:
"When I select an item from the list I should be able to add child items"
"When no…

Damian
- 1,543
- 15
- 22
1
vote
1 answer
How to trigger CanExecute method of ViewModel when a property of the Model changes?
My question is how to trigger a ViewModel method from the model.
I am developing a WPF application using MVVM. So I have a button, SubmitMedPrescCommand, (implemented using Relay Command) and a Combobox (SelectedMedPrescRepeat) that is binded to a…

nitse
- 21
- 7
1
vote
1 answer
How to activate command in dependence of changed property
I have two buttons in my WPF-(popup)control.
First is a Cancel-button, that simply closes the popup and is always enabled.
The second is the Ok-button, that should only be enabled if one of the three (bound) textboxes are changed.
The problem is,…

Telefisch
- 305
- 1
- 19
1
vote
1 answer
Command CanExecute handlers conflicting with my threaded tasks
I've started introducing some parallel programming into my WPF app to speed up the more intensive, repetitive tasks. It's going well, in that I'm seeing noticeable differences in execution time and perceived UI response.
I've obviously been careful…

Ross
- 4,460
- 2
- 32
- 59
1
vote
0 answers
WPF button canexecute style?
My first time setting "CanExecute" to anything other than "True"... I don't like the default grey background on my button when "CanExecute" is false.
For example I would like to change the background to "Red" if "CanExecute" is "False" (assuming…

mjordan
- 319
- 2
- 22
1
vote
1 answer
WPF ICommand CanExecute get called even though there is a modal window
Let's say I have an user control with a button
1
vote
2 answers
WPF CanExecute depending on more that one factor
I am facing a dilemma in using the CanExecute parameter in CommandBinding for the menu in my application.
The situation is following: the application itself can run in certain modes, e.g. the working mode, review mode, etc. Depending on the mode,…

Mike
- 1,225
- 10
- 21