protected override Script.IScriptCommand executeInner(ParameterDic pm, ItemsControl sender,
                                                              RoutedEventArgs evnt, IUIInput input, IList <IUIInputProcessor> inpProcs)
        {
            var scp = ControlUtils.GetScrollContentPresenter(sender);

            if (scp != null)
            {
                AdornerLayer adornerLayer = ControlUtils.GetAdornerLayer(sender);

                switch (AdornerMode)
                {
                case UIEventHub.AdornerMode.Attach:
                    if (adornerLayer == null)
                    {
                        return(ResultCommand.Error(new Exception("Adorner layer not found.")));
                    }
                    if (UIEventHubProperties.GetSelectionAdorner(scp) == null)
                    {
                        Window parentWindow = UITools.FindAncestor <Window>(sender);

                        Point scpPos = scp.TranslatePoint(new Point(0, 0), sender);

                        //Create and register adorner.
                        SelectionAdorner adorner = new SelectionAdorner(scp)
                        {
                            //AdjustVector = new Vector(-scpPos.X, -scpPos.Y)
                        };
                        pm.SetValue(SelectionAdornerKey, adorner);
                        UIEventHubProperties.SetSelectionAdorner(scp, adorner);
                        UIEventHubProperties.SetLastScrollContentPresenter(sender, scp);     //For used when detach.

                        adornerLayer.Add(adorner);
                    }
                    break;

                case UIEventHub.AdornerMode.Detach:

                    var lastScp     = UIEventHubProperties.GetLastScrollContentPresenter(sender); //For used when detach.
                    var lastAdorner = UIEventHubProperties.GetSelectionAdorner(scp);
                    if (lastAdorner != null)
                    {
                        adornerLayer.Remove(lastAdorner);
                    }

                    UIEventHubProperties.SetLastScrollContentPresenter(sender, null);
                    UIEventHubProperties.SetSelectionAdorner(scp, null);
                    pm.SetValue <Object>(SelectionAdornerKey, null);
                    break;

                case UIEventHub.AdornerMode.Update:
                    var updateAdorner = pm.GetValue <SelectionAdorner>(SelectionAdornerKey) ??
                                        UIEventHubProperties.GetSelectionAdorner(scp);

                    if (updateAdorner == null)
                    {
                        return(ResultCommand.Error(new Exception("Adorner not found.")));
                    }

                    updateAdorner.IsSelecting = UIEventHubProperties.GetIsSelecting(sender);
                    Point startAdjusted = pm.GetValue <Point>("{StartPosition}");
                    Point current       = pm.GetValue <Point>(CurrentPositionKey);
                    updateAdorner.SetValue(SelectionAdorner.StartPositionProperty, startAdjusted);
                    updateAdorner.SetValue(SelectionAdorner.EndPositionProperty, current);
                    break;
                }
            }
            return(NextCommand);
        }
        protected override Script.IScriptCommand executeInner(ParameterDic pm, ItemsControl ic,
                                                              RoutedEventArgs evnt, IUIInput input, IList <IUIInputProcessor> inpProcs)
        {
            var scp = ControlUtils.GetScrollContentPresenter(ic);

            if (scp != null)
            {
                AdornerLayer adornerLayer = ControlUtils.GetAdornerLayer(ic);

                switch (AdornerMode)
                {
                case UIEventHub.AdornerMode.Attach:
                    if (adornerLayer == null)
                    {
                        return(ResultCommand.Error(new Exception("Adorner layer not found.")));
                    }
                    if (UIEventHubProperties.GetSelectedItemsAdorner(scp) == null)
                    {
                        //Create and register adorner.
                        SelectedItemsAdorner adorner = new SelectedItemsAdorner(scp);
                        pm.SetValue(SelectedItemsAdornerKey, adorner);
                        UIEventHubProperties.SetSelectedItemsAdorner(scp, adorner);
                        UIEventHubProperties.SetLastScrollContentPresenter(ic, scp);     //For used when detach.

                        adornerLayer.Add(adorner);
                    }
                    break;

                case UIEventHub.AdornerMode.Detach:

                    var lastScp     = UIEventHubProperties.GetLastScrollContentPresenter(ic); //For used when detach.
                    var lastAdorner = UIEventHubProperties.GetSelectedItemsAdorner(scp);
                    if (lastAdorner != null)
                    {
                        adornerLayer.Remove(lastAdorner);
                    }

                    UIEventHubProperties.SetLastScrollContentPresenter(ic, null);
                    UIEventHubProperties.SetSelectedItemsAdorner(scp, null);
                    pm.SetValue <Object>(SelectedItemsAdornerKey, null);
                    break;

                case UIEventHub.AdornerMode.Update:
                    var updateAdorner = pm.GetValue <SelectedItemsAdorner>(SelectedItemsAdornerKey) ??
                                        UIEventHubProperties.GetSelectedItemsAdorner(scp);

                    if (updateAdorner == null)
                    {
                        return(ResultCommand.Error(new Exception("Adorner not found.")));
                    }

                    Point current = pm.GetValue <Point>(CurrentPositionAdjustedKey);

                    if (updateAdorner.CurrentPosition.X == -1 && updateAdorner.CurrentPosition.Y == -1)
                    {
                        //If the adorner is not initialized.
                        updateAdorner.SetValue(SelectedItemsAdorner.CurrentPositionProperty, current);
                        updateAdorner.SetValue(SelectedItemsAdorner.ItemsProperty, ic.ItemsSource);
                    }
                    else
                    {
                        updateAdorner.SetValue(SelectedItemsAdorner.CurrentPositionProperty, current);
                    }
                    break;
                }
            }
            return(NextCommand);
        }