Initial Commit
This commit is contained in:
54
PortfolioManager/Command/RelayCommand.cs
Normal file
54
PortfolioManager/Command/RelayCommand.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
//using System.Windows.Input;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using Avalonia.Labs.Input;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace PortfolioManager.Command
|
||||
{
|
||||
public class MyRelayCommand : IRelayCommand
|
||||
{
|
||||
readonly Action<object> execute;
|
||||
readonly Predicate<object> canExecute;
|
||||
public MyRelayCommand(Action<object> execute)
|
||||
: this(execute, null)
|
||||
{
|
||||
}
|
||||
|
||||
public MyRelayCommand(Action<object> execute, Predicate<object> canExecute)
|
||||
{
|
||||
if (execute == null) throw new ArgumentNullException("execute");
|
||||
this.execute = execute;
|
||||
this.canExecute = canExecute;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return canExecute == null ? true : canExecute(parameter);
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
// CommandManager.RequerySuggested += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
// CommandManager.RequerySuggested -= value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
execute(parameter);
|
||||
}
|
||||
|
||||
public void NotifyCanExecuteChanged()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user