/// <inheritdoc cref="RelayCommand(ExecuteHandler{object}, CanExecuteHandler{object})"/> public RelayCommand(ExecuteHandler execute, CanExecuteHandler canExecute = null) : this ( p => execute(), p => canExecute?.Invoke() ?? true ) { }
public bool CanExecute(object parameter = null) { if (!m_enabled) { return(false); } var canExecute = CanExecuteHandler?.Invoke(parameter); //either no handler (enabled) or use value returned by handler return(!canExecute.HasValue || canExecute.Value); }
private static void RaiseCanExecute(IntPtr cPtr, IntPtr sender, IntPtr e) { try { if (Noesis.Extend.Initialized) { long ptr = cPtr.ToInt64(); if (sender == IntPtr.Zero && e == IntPtr.Zero) { _CanExecute.Remove(ptr); return; } CanExecuteHandler handler = null; if (!_CanExecute.TryGetValue(ptr, out handler)) { throw new InvalidOperationException("Delegate not registered for CanExecute event"); } handler?.Invoke(Noesis.Extend.GetProxy(sender, false), new CanExecuteRoutedEventArgs(e, false)); } } catch (Exception exception) { Noesis.Error.UnhandledException(exception); } }
/// <summary>Вызов разрешающего метода команды</summary> /// <param name="parameter">Параметр команды</param> /// <returns>True - если выполнение команды разрешено</returns> public bool CanExecute(object parameter) => _canExecute == null ? true : _canExecute.Invoke(parameter);
public bool CanExecute(object parameter) => CanExecuteHandler?.Invoke(parameter) ?? true;
/// <summary>Вызов метода, возвращающего состояние команды.</summary> /// <param name="parameter">Параметр команды.</param> /// <returns><see langword="true"/> - если выполнение команды разрешено.</returns> public bool CanExecute(object parameter) => canExecute?.Invoke(parameter) ?? true;
/// <inheritdoc cref="ICommand.CanExecute(object)"/> public bool CanExecute(object parameter) { return(canExecute?.Invoke(parameter) ?? true); }