Ошибка CS0246: имя или тип пространства имен «ICommandAttribute» не может быть найден или обработан (отсутствует ссылка на использование или сборку?)
Это мой код:
Код: Выделить всё
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using PimStreamingApp.Maui.Services;
namespace PimStreamingApp.Maui.ViewModels;
public partial class LoginViewModel : ObservableObject
{
private readonly IAuthService _authService;
[ObservableProperty] private string email = "";
[ObservableProperty] private string password = "";
[ObservableProperty] private bool isBusy;
public LoginViewModel(IAuthService authService)
{
_authService = authService;
}
[ICommand]
private async Task LoginAsync()
{
if (IsBusy)
return;
IsBusy = true;
try
{
var token = await _authService.LoginAsync(Email, Password);
if (!string.IsNullOrEmpty(token))
{
await Shell.Current.GoToAsync("//dashboard");
}
else
{
await Application.Current.MainPage.DisplayAlert("Erro", "Credenciais inválidas", "OK");
}
}
finally
{
IsBusy = false;
}
}
[ICommand]
private async Task RegisterAsync()
{
// abre página de registro se existir
await Application.Current.MainPage.DisplayAlert("Info", "Use o Swagger para registrar (ou implemente RegisterPage).", "OK");
}
}
Любой ответ полезен, спасибо.
Репозиторий можно найти по адресу https://github.com/p3dromelo/PimStreamingApp.Maui, если кто-то захочет проверить его дальше.>
Подробнее здесь: https://stackoverflow.com/questions/798 ... 0246-error
Мобильная версия