public void AttachToElement(FrameworkElement element)
        {
            //if (TargetElement != null)
            //{
            //   if (ReferenceEquals(TargetElement.ElementSelectionService, element))
            //   {
            //      log.DebugFormat("Extender {0} is already attached to element {1}", this, element);
            //      return;
            //   }
            //   throw new InvalidOperationException("Cannot re-attach an attached extender");
            //}

            TargetElementProxy = UIServiceProvider.GetService <IMultiSelectionService>(element);
            SetSelectionExtender(element, this);
            var selectionView = GetSelectionView(element);

            this.AttachSelectionModel(null, selectionView);
            TargetElementProxy.SelectionChanged += TargetElement_SelectionChanged;

            currentItemTracker = UIServiceProvider.GetService <ICurrentItemService>(element, false);
            currentItemTracker.CurrentChanged         += new EventHandler(currentItemTracker_CurrentChanged);
            currentItemTracker.PreviewCurrentChanging += CurrentItemTracker_PreviewCurrentChanging;
            //if (currentItemTracker != null)
            //{
            //   selectionModeManager = new SelectionModeManager(TargetElement);
            //}

            var inputService = UIServiceProvider.GetService <InputService>(TargetElement);

            inputService.RegisterMouseActionGestures(ToggleSelection, new MouseGesturesFactory(MouseAction.LeftClick, ModifierKeys.Control));
            inputService.RegisterKeyActionGestures(ToggleSelection, new KeyGesturesFactory(Key.Space, ModifierKeys.Control));
            //inputService.RegisterMouseActionGestures(SelectRange, new MouseGesturesFactory(MouseAction.LeftClick, ModifierKeys.Shift));
        }
        protected override object GetAdapter(Type adapterType)
        {
            if (adapterType == typeof(ICurrentItemService))
            {
                if (currentItemProvider == null)
                {
                    currentItemProvider = new DataGridCurrentItemService();
                    ((IUIService)currentItemProvider).AttachToElement(DataGridElement);
                }
                return(currentItemProvider);
            }

            if (adapterType == typeof(IElementEditStateService))
            {
                return(null);
            }

            return(base.GetAdapter(adapterType));
        }
 public void Initialize(IMultiSelectionService element, ICurrentItemService currentItemTracker)
 {
     ElementSelectionService = element;
     CurrentItemTracker      = currentItemTracker;
 }