IRelayCommand{T}.cs 1.2 KB

1234567891011121314151617181920212223242526272829
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Windows.Input;
  5. namespace CommunityToolkit.Mvvm.Input;
  6. /// <summary>
  7. /// A generic interface representing a more specific version of <see cref="IRelayCommand"/>.
  8. /// </summary>
  9. /// <typeparam name="T">The type used as argument for the interface methods.</typeparam>
  10. public interface IRelayCommand<in T> : IRelayCommand
  11. {
  12. /// <summary>
  13. /// Provides a strongly-typed variant of <see cref="ICommand.CanExecute(object)"/>.
  14. /// </summary>
  15. /// <param name="parameter">The input parameter.</param>
  16. /// <returns>Whether or not the current command can be executed.</returns>
  17. /// <remarks>Use this overload to avoid boxing, if <typeparamref name="T"/> is a value type.</remarks>
  18. bool CanExecute(T? parameter);
  19. /// <summary>
  20. /// Provides a strongly-typed variant of <see cref="ICommand.Execute(object)"/>.
  21. /// </summary>
  22. /// <param name="parameter">The input parameter.</param>
  23. /// <remarks>Use this overload to avoid boxing, if <typeparamref name="T"/> is a value type.</remarks>
  24. void Execute(T? parameter);
  25. }