I am building a MAUI app using Visual Studio 2022 (.NET 7.0) and the Community Toolkit for MVVM v8.2. I have created a RelayCommand in my viewmodel class:
public partial class LoginViewModel : ObservableObject
{
[RelayCommand]
async Task Login()
{
// do stuff
}
}
And my XAML looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp4.Views.LoginPage"
Shell.NavBarIsVisible="False"
Title="Login"
BackgroundImageSource="background.jpg">
<VerticalStackLayout>
<Button
Text="Login"
WidthRequest="100"
CornerRadius="20"
HorizontalOptions="Center"
Clicked="{Binding LoginCommand}"
/>
</VerticalStackLayout>
</ContentPage>
When I compile, I get this error:
XFC0009: No property, BindableProperty, or event found for "Clicked", or mismatching type between value and property.
This error seems to be indicating that there is no "Clicked" property or event, or that the type doesn't match. What am I doing wrong?
using Command instead ofClicked solved all (this seems me a bit... unusual, coming from net winforms I've used to clicked event but... OK)