using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; namespace MauiMvvm.ViewModels; public class GreetingViewModel : ObservableObject { private string name = ""; private string greeting = "Enter a name to begin."; public string Name { get => name; set => SetProperty(ref name, value); } public string Greeting { get => greeting; set => SetProperty(ref greeting, value); } public IRelayCommand GreetCommand { get; } public GreetingViewModel() { GreetCommand = new RelayCommand(Greet); } private void Greet() { Greeting = string.IsNullOrWhiteSpace(Name) ? "Hello from MVVM!" : $"Welcome, {Name.Trim()}!"; } }