using Caliburn.Micro;
using EPD.Models;
using SFMVVM.EventModels;
using SFMVVM.Models;
using Syncfusion.Windows.PropertyGrid;
using Syncfusion.Windows.Shared;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Input;

namespace SFMVVM.ViewModels
{
    public class PropertyGridViewModel : Screen, IHandle<RibbonBttnClick_DemoButton>
    {
        private IEventAggregator _events;

        public PropertyGridViewModel(IEventAggregator eventAggregator)
        {
            _events = eventAggregator;
            _events.SubscribeOnPublishedThread(this);
        }

        private object _selectedDetails;

        public object SelectedDetails
        {
            get { return _selectedDetails; }
            set { _selectedDetails = value; NotifyOfPropertyChange(() => SelectedDetails); }
        }

        public Task HandleAsync(RibbonBttnClick_DemoButton message, CancellationToken cancellationToken)
        {
            ContactDetailDisplayModel model = new ContactDetailDisplayModel();
            model.PersonName = new PersonDisplayModel();
            model.Address = new ContactAddressDisplayModel();

            SelectedDetails = model;


            return Task.CompletedTask;
        }

        private PropertyItem selectedPropertyItem;

        public PropertyItem SelectedPropertyItem
        {
            get { return selectedPropertyItem; }
            set
            {
                selectedPropertyItem = value;
                NotifyOfPropertyChange(() => SelectedPropertyItem);
                NotifyOfPropertyChange(() => SelectedDetails);
                //this.RaisePropertyChanged(() => this.SelectedPropertyItem);
            }
        }



        private ICommand PG_Loaded(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Loaded");
            return null;
        }


    }
}
