canexecute

Can I suppress the “CanExecute” call within the MVVM pattern

走远了吗. 提交于 2019-12-25 04:56:13
问题 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 Level 3.1 Level 3.2 Levels 1, 2 and 3 are loaded at run time. Levels 1.1, 3.1 and 3.2 would not be loaded until their respective parents are clicked. Levels below 1.1 etc. are loaded the same way, by clicking on their parent. My issue is when I click on

Button using ICommand does not get disabled?

六眼飞鱼酱① 提交于 2019-12-24 00:57:03
问题 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 CanExecute is false...button is not disabled...WHEN button CONTENT is IMAGE But, when button content is text..enable/disable works fine. <Button DockPanel.Dock="Top" Command="{Binding Path=MoveUpCommand}"> <Button.Content> <Image Source="/Resources

Can Execute of a ICommand while a Context menu open

我是研究僧i 提交于 2019-12-23 01:59:11
问题 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 to be hit(Checks) for each time while opening the ContextMenu . <Border> <Border.ContextMenu> <ContextMenu> <MenuItem Command="{Binding SaveCommand, Source={StaticResource vm}}" CommandParameter="{Binding}" Header="Menu1" /> </ContextMenu> <

Eclipse Luna: Handlers' @CanExecute methods not called

柔情痞子 提交于 2019-12-19 09:46:47
问题 I'm having a problem with command handlers in Eclipse Luna RCP. In my E4 application model, I defined some commands and related handlers that must be enabled only under certain circumstances. For this reason, in my handler POJOs, I implemented methods annotated with @CanExecute where I check the required conditions. I also defined menu and toolbar items associated with those commands. The problem is that my @CanExecute methods aren't properly invoked and, as a consequence, menu and toolbar

MVVM RelayCommand CanExecute

僤鯓⒐⒋嵵緔 提交于 2019-12-19 06:31:20
问题 I'm implementing an RelayCommand with an execute and an canExecute part. The RelayCommand works when it is without the canExecute part, however when I add the canExecute part, the command locks the button. The RelayCommand only checks whether or not the button can be executed as long as the CanExecute part is true. Once the canExecute part becomes false, the button can no longer be clicked, even if it is supposed to. How do I make sure that every time I click on the button it controls whether

What is CanExecuteChanged for?

强颜欢笑 提交于 2019-12-18 03:12:28
问题 Can I use CanExecuteChanged to change the "can execute" condition? Or else... "for what" its used? 回答1: No you can not use it to change the can execute state. It is an event and objects which participate in the ICommand pattern can choose to listen to this event e.g. a button may use this event to know when to re-query the commands state (by calling the can execute method) to set its enabled state. In order for the can execute pattern to be useful there needs to be something that can be used

What is CanExecuteChanged for?

假如想象 提交于 2019-12-18 03:12:21
问题 Can I use CanExecuteChanged to change the "can execute" condition? Or else... "for what" its used? 回答1: No you can not use it to change the can execute state. It is an event and objects which participate in the ICommand pattern can choose to listen to this event e.g. a button may use this event to know when to re-query the commands state (by calling the can execute method) to set its enabled state. In order for the can execute pattern to be useful there needs to be something that can be used

MVVM: command and canExecute flag

主宰稳场 提交于 2019-12-11 22:42:22
问题 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 the right way. This is my xaml (as you can see, all my fields are in a layout control): <dxlc:LayoutGroup Header="Configurazione tecnica" View="GroupBox" Orientation="Vertical"> <dxlc:LayoutItem Label="Tipo sistema"> <dxe:ComboBoxEdit

ICommand doesn't update the IsEnabled on a button using CanExecute

与世无争的帅哥 提交于 2019-12-10 17:18:22
问题 I have a very simple button binded to a command <Button Content="Add" Margin="10,10,10,0" Command="{Binding SaveCommand}" ></Button> My command code public ICommand SaveCommand { get; internal set; } private bool CanExecuteSaveCommand() { return DateTime.Now.Second % 2 == 0; } private void CreateSaveCommand() { SaveCommand = new DelegateCommand(param => this.SaveExecute(), param => CanExecuteSaveCommand()); } public void SaveExecute() { PharmacyItem newItem = new PharmacyItem(); newItem.Name

Eclipse Luna: Handlers' @CanExecute methods not called due to wrong context

点点圈 提交于 2019-12-02 15:23:30
问题 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 manually). But alas, the cure didn't work :-(. I drilled down with the debugger to find the root cause of failure. I found that in HandlerServiceHandler.class the method setEnabled(Object evaluationContext) fails. This is due to the extraction of the wrong