using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Interactivity;
using System.Windows;
using System.Windows.Media;
using MECF.Framework.Common.Aitex.Core.RT.EMS;

namespace MECF.Framework.UI.Client.CenterViews.Maintain.Behavior
{
    public class DataGridSelectionChangedScrollChangedBehavior : Behavior<DataGrid>
    {
        protected override void OnAttached()
        {
            AssociatedObject.SelectionChanged += SelectedOperation;
        }

        private void SelectedOperation(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 1)
            {
                if (e.AddedItems[0] is MaintainerItemInfo)
                {
                    AssociatedObject.ScrollIntoView(e.AddedItems[0]);
                }
            };
        }
    }
}
