Questions tagged [canexecute]

66 questions
1
vote
1 answer

Why does my button with an ICommand binding not immediately appear disabled when clicked?

I have a simple WPF program with an ICommand. I am finding that the button doesn't enable/disable as I would expect. I can illustrate this best with a contrived code example: class Reload : ICommand { private readonly BackgroundWorker _bworker…
user2023861
  • 8,030
  • 9
  • 57
  • 86
1
vote
2 answers

Does calling "command.Execute" implicitly call CanExecute first?

I just implemented a call of Execute for a Command without calling CanExecute first. From debugging I would tell that CanExecute is called though; however, I'm not sure if this is coincidence. I'd like to know if I can rely on the fact that…
Em1
  • 1,077
  • 18
  • 38
1
vote
1 answer

Mark object (not entity, not framework) as dirty in WPF ViewModel

In my viewmodel, there is a property CurrentObject of the type SomeDomainType which is serializeable. There is a form to edit its properties, and one of the buttons is "Commit Changes", databound to the ICommand CommitChangesCommand. Now I expect…
heltonbiker
  • 26,657
  • 28
  • 137
  • 252
1
vote
1 answer

Can Execute of a ICommand while a Context menu open

A Control has its ContextMenu and its MenuItem is bound to an ICommand. ICommand's Can Execute has some code to enable and disable the MenuItem. This hits while loading and checks for Can Execute but it can hit while open the ContexMenu and it need…
Sankarann
  • 2,625
  • 4
  • 22
  • 59
1
vote
4 answers

TextBox binding not refreshed when cleared-up

I have a Form that contains some TextBox bound to some object property:
goul
  • 813
  • 1
  • 13
  • 32
1
vote
1 answer

Error in CanExecute() - how to get rid of dialog?

I'm trying to handle exceptions in a dialog so that if any exception occurs, the dialog will be closed and the application will not crash. As you can see, I use a simple try-catch block: IDialogView dialog = null; try { if (_dialogViewModel ==…
STiLeTT
  • 1,023
  • 10
  • 23
0
votes
1 answer

CanExecute part of a command is not called in all cases. what does determine it?

In my WPF application using MVVM I noticed that in some cases the CanExecute part of a Command is not called, so I was wondering what decides when this (kind of) method is called?
Michel Keijzers
  • 15,025
  • 28
  • 93
  • 119
0
votes
1 answer

Dependency Property command's CanExecute() not updating

I have a user control and within I defined the following property: public string MyProperty { get { return (string)GetValue(MyPropertyProperty); } set { SetValue(MyPropertyProperty, value); } } public static readonly…
Anno
  • 761
  • 1
  • 10
  • 22
0
votes
1 answer

Why is my ContextMenu item bound to a RelayCommand is always disabled?

I'm working on my first big WPF MVVM application now, which uses MVVM Light Toolkit in combination with Josh Smith's RelayCommand. The problem I run into is that I bound this command to an item in a ContextMenu, which keeps disabled all the…
Thomas
  • 129
  • 1
  • 9
0
votes
1 answer

How to set CanExecuteCommand correctly for WPF double TextBox?

For this example I use Prism.WPF. I have a TextBox in my WPF and a button: and…
Anno
  • 761
  • 1
  • 10
  • 22
0
votes
1 answer

Cache CanExecute (or anything) in WPF?

The Cache object in System.Web is pretty freaking nice. I handle my CommandBinding.CanExecute sort of like this: CommandBindings[0].CanExecute += (s, e) => { e.CanExecute = NotInsignificantRoutine(); }; In my scenario, the return value of…
Jerry Nixon
  • 31,313
  • 14
  • 117
  • 233
0
votes
2 answers

WPF CanExecute and ThreadPool

My application executes a webservice call and when it happens, the IsExecuting status is set to true and the execute button is disabled. Because the application is not responsive during this period i change the process so the execution is happening…
Sys
  • 443
  • 1
  • 8
  • 28
0
votes
1 answer

Unit testing ICommand.CanExecute when using CommandManager

(Part of) my ICommand implementation is: public void RaiseCanExecuteChanged() { CommandManager.InvalidateRequerySuggested(); } public event EventHandler CanExecuteChanged { add { …
eriksmith200
  • 2,159
  • 5
  • 22
  • 33
0
votes
1 answer

How to exlude a method with cane gem to avoid abc complexity

Hi i am working on a RoR project with cane gem. I have a method inside an interactor. I am getting Methods exceeded maximum allowed ABC complexity (1): For this method. I want to exclude this method to check complexity. So I…
awsm sid
  • 595
  • 11
  • 28
0
votes
1 answer

Can I add one more condition to canExecute predicate?

I am using Josh Smith's RelayCommand in my WPF MVVM application. I have a ViewModel. Inside that I have a reference to another ViewModel. The child ViewModel has a property of type ICommand in it. In my parent ViewModel, can I add one more condition…
Relativity
  • 6,690
  • 22
  • 78
  • 128