Untitled

mail@pastecode.io avatar
unknown
csharp
a year ago
1.2 kB
0
Indexable
Never
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace SampleApplication
{
    public partial class MainPage : ContentPage
    {
        int licznik = 0;

        ObservableCollection<TodoItem> TodoItems = new ObservableCollection<TodoItem>();

        public MainPage()
        {
            InitializeComponent();
        }

        async void btnAdd_Clicked(System.Object sender, System.EventArgs e)
        {
            string result = await DisplayPromptAsync("Create TODO item", "What to do?");

            TodoItems.Add(new TodoItem()
            {
                Name = result,
                CreatedAt = DateTime.Now
            });

            taskList.ItemsSource = TodoItems;
        }

        async void btnMin_Clicked(System.Object sender, System.EventArgs e)
        {
            TodoItems.Remove(TodoItems.Last());
            taskList.ItemsSource = TodoItems;
        }
    }

    public class TodoItem
    {
        public string Name { get; set; }
        public DateTime CreatedAt { get; set; }
    }
}