/// <summary> /// Defines the method that determines whether the command can execute in its current state. /// </summary> /// <param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to null.</param> /// <returns> /// true if this command can be executed; otherwise, false. /// </returns> public bool CanExecute(object parameter) { WindowCanExecuteArgs args = new WindowCanExecuteArgs((parameter as Window) ?? Window, parameter); if (args.Window != null) { CanExecuteHandler temp = OnCanExecute; if (temp != null) { temp(this, args); } else { IfNoHandlerOnCanExecute(this, args); } } return(args.CanExecute); }
protected override void IfNoHandlerOnCanExecute(object window, WindowCanExecuteArgs e) { e.CanExecute = e.Window.IsLoaded; }
/// <summary> /// Defines the method that determines whether the command can execute in its current state. /// </summary> /// <param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to null.</param> /// <returns> /// true if this command can be executed; otherwise, false. /// </returns> public bool CanExecute(object parameter) { WindowCanExecuteArgs args = new WindowCanExecuteArgs((parameter as Window) ?? Window, parameter); if (args.Window != null) { CanExecuteHandler temp = OnCanExecute; if (temp != null) { temp(this, args); } else { IfNoHandlerOnCanExecute(this, args); } } return args.CanExecute; }
/// <summary>Determines whether this instance can execute on specified Window /// (or the default Window, if you pass in null). /// </summary> /// <param name="source">The Window.</param> /// <returns> /// <c>true</c> if this instance can execute on the specified Window; otherwise, <c>false</c>. /// </returns> protected abstract void IfNoHandlerOnCanExecute(object source, WindowCanExecuteArgs e);
/// <summary> /// Determines whether this instance can execute on specified Window /// (or the default Window, if you pass in null). /// </summary> /// <param name="window">The Window.</param> /// <param name="e">The event arguments</param> protected override void IfNoHandlerOnCanExecute(object window, WindowCanExecuteArgs e) { e.CanExecute = e.Window.IsLoaded; }