我正在尝试将两个值传递给MvxCommand,如下面的代码所示。第一个值是string类型,而第二个值是Enum。 但是我收到以下错误:
currentYearSavingDays, currentYearSavingXMins, currentYearSavingNXMins, currentYearUsedDays, currentYearUsedXMins, yearLimitRemainingDays, yearLimitRemainingXMins, totalYearlyDays, totalYearlyXMins, totalSavingDays, totalSavingMins, totalUsableDays, totalUsableMins, nextYearTotalUsableDays, nextYearTotalUsableMins, dayWorkMinutes, previousYearRemainingDays, previousYearRemainingMins = 0;
请让我知道如何解决此错误。
代码:
the non-generic type MvxCommand can’t be used with type arguments
答案 0 :(得分:1)
非泛型MvxCommand不能与类型参数一起使用
这是源代码段:
namespace MvvmCross.Commands
{
public interface IMvxCommand : ICommand
{
void RaiseCanExecuteChanged();
void Execute();
bool CanExecute();
}
public interface IMvxCommand<T> : ICommand
{
[Obsolete("Use the strongly typed version of Execute instead", true)]
new void Execute(object parameter);
[Obsolete("Use the strongly typed version of CanExecute instead", true)]
new bool CanExecute(object parameter);
void RaiseCanExecuteChanged();
void Execute(T parameter);
bool CanExecute(T parameter);
}
}
您会看到IMvxCommand<T>
参数是T
因此,如果您想传递两个参数,我认为您可以使用Tuple
将它们变成单个对象。
例如
new MvxCommand<Tuple<string, VRTEnum>>(Action);