Exemplo n.º 1
0
        // We use the ItemStatus to convey read-only property selection status
        protected override string GetItemStatusCore()
        {
            FrameworkElement selection = _control.Selection;
            string           status;

            if (selection != null)
            {
                ISelectionStop selectionStop = PropertySelection.GetSelectionStop(selection);
                status = selectionStop == null ? null : selectionStop.Description;

                if (status == null)
                {
                    status = string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.PropertyEditing_SelectionStatus_Unknown,
                        selection.GetType().Name);
                }
            }
            else
            {
                status = Resources.PropertyEditing_SelectionStatus_Empty;
            }

            return(status);
        }
Exemplo n.º 2
0
        // Keyboard Navigation

        protected override void OnKeyDown(KeyEventArgs e)
        {
            // Intercept Up, Down, Left, Right key strokes and use them to navigate around the
            // the control
            //
            if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down)
            {
                if (_selection != null && !e.Handled)
                {
                    if (object.Equals(
                            Keyboard.FocusedElement,
                            VisualTreeUtils.FindFocusableElement <FrameworkElement>(_selection)))
                    {
                        ISelectionStop selectionStop = PropertySelection.GetSelectionStop(_selection);
                        if (selectionStop != null)
                        {
                            if (selectionStop.IsExpandable)
                            {
                                if ((e.Key == Key.Right && !selectionStop.IsExpanded) ||
                                    (e.Key == Key.Left && selectionStop.IsExpanded))
                                {
                                    selectionStop.IsExpanded = !selectionStop.IsExpanded;
                                    e.Handled = true;
                                }
                            }
                        }

                        if (!e.Handled)
                        {
                            SearchDirection  direction = e.Key == Key.Up || e.Key == Key.Left ? SearchDirection.Previous : SearchDirection.Next;
                            FrameworkElement nextStop  = PropertySelection.FindNeighborSelectionStop <FrameworkElement>(_selection, direction);

                            // If need to select something, select it
                            if (nextStop != null)
                            {
                                SelectAndFocus(nextStop, StealFocusMode.Always);
                            }

                            e.Handled = true;
                        }
                    }
                }
            }

            base.OnKeyDown(e);
        }