using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace MauiBrokenBindings.PageModels
{
    public partial class MainPageModel : ObservableObject
    {

        [ObservableProperty]
        private List<DataModel> _data = [new("Test"), new("abc"), new("123456"), new("qwertz")];

        [RelayCommand]
        private void DataSelected(DataModel data)
        {
            MainThread.BeginInvokeOnMainThread(async void () => await Shell.Current.DisplayAlertAsync("Data selected", data.Text, "OK"));
        }
    }

    public class DataModel(string text)
    {
        public string Text { get; set; } = text;
    }
}