Questions tagged [canexecute]
66 questions
0
votes
2 answers
WPF commands CanExecute validation inside a template
I have a nested datagrid where I have + and - buttons that are bound to RelayCommands that add a new row or delete the current one respectively. The minus button command's CanExecute logic is supposed to disable the current row's minus button if…

Disodium
- 105
- 1
- 2
- 7
0
votes
1 answer
MVVM property with a linked complex class and CanExecute Relay Command not working
I have a entity class in a C# library class and linked to Silverlight class library
(entities must be in C# class because of legacy compatiblity with other systems)
Example (C# library):
public class TestClass
{
private string…

KolarJ
- 21
- 3
0
votes
1 answer
Command Binding issues in AvalonDock
I have created an application where there's a series of command bindings attached to the MainWindow of my application:
(Code simplified for brevity)
…

Xelnath
- 65
- 8
0
votes
2 answers
Notify user that command could not be executed
I have a TextBox that is tied to a command like this:
…

Kjara
- 2,504
- 15
- 42
0
votes
1 answer
CanExecute not raised when context menu opens
I know there are a handful of related questions but none of those helped me finding the issue.
Most answers suggest to implement CanExecuteChanged as shown in this answer. Well, that's not the solution to my problem. I've got an implementation of…

Em1
- 1,077
- 18
- 38
0
votes
0 answers
WPF - Keep menu item enabled even when command's canExecute returns false
By default menu items are disabled when it's command's canExecute returns false. Is it possible to override this behavior? I need to keep menu item enabled even if canExecute is returning false without touching canExecute. Setting isEnabled to true…

Sandy
- 1
- 1
0
votes
1 answer
Can I suppress the "CanExecute" call within the MVVM pattern
I am working with a tree structure using WPF and the MVVM pattern. I start out by creating 20 root nodes and lazy loading the child nodes as each node is clicked. So for instance ... if I have the following:
Level 1
Level 1.1
Level 2
Level 3
…
user26901
0
votes
2 answers
How to get a MenuItem from within its CanExecute handler?
How can I get access to the related MenuItem? It has been created on the fly, so I cannot just use it by a name in the xaml file.
private void menuItem_canExecute(object sender, CanExecuteRoutedEventArgs e)
{
var snd = sender; // This is the…

Pollitzer
- 1,580
- 3
- 18
- 28
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
1 answer
CanExecute of ApplicationCommand does not update
I would like to call an ApplicationCommand with a MenuItem-Click:
In my ViewModel-Constructor I inizialize my bindings with:
CommandBinding…

MisterPresident
- 563
- 7
- 20
0
votes
2 answers
What should go in CanExecute?
I think that there is a specific answer to this.
If I have a command binding
private bool CanExecute(Object args){
// Should this just be null checks?
// Should it also contain logic?
// example:
return this.SelectedObject != null;
//…

DotNetRussell
- 9,716
- 10
- 56
- 111
0
votes
2 answers
MVVM: command and canExecute flag
I'm working with my first command with a dynamic flag canExecute.
I have my save command, that it must enabled only when user makes some data changes.
I was thinking about binding an action when the mods are made, but I get errors, maybe this isn't…

Piero Alberto
- 3,823
- 6
- 56
- 108
0
votes
0 answers
Eclipse Luna: Handlers' @CanExecute methods not called due to wrong context
I upgraded my eclipse RCP application from Juno to Luna.
This caused my application toolbar to be permenantly disabled.
I found a solution in this thread: Eclipse Luna: Handlers' @CanExecute methods not called (Solution: generate event…

whomaniac
- 1,258
- 4
- 15
- 22
0
votes
1 answer
MVVM Light - usage of RaiseCanExecuteChanged for RelayCommand
I'm using MVVM Pattern. Im my View, I have textboxes for Person details, which one of them is idBox. Also, the view consists of several buttons, which one of them is editModeBtn.
I want the editModeBtn to be enabled only when there is a valid int…

Cod Fish
- 917
- 1
- 8
- 37
0
votes
1 answer
implement CanExecute MVVM light using ICommand
I have a program, where a button should only be active if the corresponding userControl has focus.
I am using MVVM light, and got a command implementing the ICommand interface.
I have tried using the Keyboard.FocusedElement, but this returns…

Jesper Plantener
- 229
- 3
- 16