using ListViewTemplateCellDemo.Portable.ViewModels;
using Telerik.XamarinForms.DataControls.ListView;
using Xamarin.Forms;

namespace ListViewTemplateCellDemo.Portable
{
    public partial class StartPage : ContentPage
    {
        public StartPage()
        {
            InitializeComponent();
        }

        private void ListView_OnItemTapped(object sender, ItemTapEventArgs e)
        {
            var book = e.Item as BookItemViewModel;

            if (book == null)
                return;

            // Simply toggle the flag to show or hide content and effectively expand and collapse the cell area
            // This happens because of <StackLayout IsVisible="{Binding ShowDetails}"... >
            book.ShowDetails = !book.ShowDetails;
        }
    }
}