示例#1
0
            private void InitEnabledSync()
            {
                if (commandState == null || !(source is UIElement element))
                {
                    return;
                }

                // Creating a CommandState.Enabled -> UIElement.IsEnabled binding
                syncEnabledBinding = commandState.CreatePropertyBinding(nameof(commandState.Enabled), nameof(element.IsEnabled), element);
            }
        public KGyCommandAdapter(ICommand command, CommandState state = null)
        {
            wrappedCommand = command;
            if (state == null)
            {
                return;
            }

            // if a state was passed to the constructor, then we sync its Enabled state with CanExecute
            this.state = state;
            state.CreatePropertyBinding(nameof(state.Enabled), nameof(CanExecute), this);
        }