Exemple #1
0
        // Find the closest IsSelectable parent and select it.  Don't mess with focus.
        //
        private void Select(DependencyObject visualSource)
        {
            if (visualSource != null)
            {
                FrameworkElement selection = PropertySelection.FindParentSelectionStop <FrameworkElement>(visualSource);

                if (selection != _selection)
                {
                    // Unselect anything that was selected previously
                    if (_selection != null)
                    {
                        PropertySelection.SetIsSelected(_selection, false);
                    }

                    _selection = selection;

                    // Select whatever we need to select now
                    if (_selection != null)
                    {
                        PropertySelection.SetIsSelected(_selection, true);

                        // Bring the full PropertyContainer into view, if one exists
                        FrameworkElement focusableElement        = VisualTreeUtils.FindFocusableElement <FrameworkElement>(_selection) ?? _selection;
                        FrameworkElement parentPropertyContainer = VisualTreeUtils.FindVisualAncestor <PropertyContainer>(focusableElement);
                        FrameworkElement bringIntoViewElement    = parentPropertyContainer ?? focusableElement;

                        bringIntoViewElement.BringIntoView();

                        // As soon as the user manually selects a property, automatically switch to Sticky mode
                        _selectionMode = PropertySelectionMode.Sticky;
                    }
                }
            }
        }
Exemple #2
0
        // Attempts to resolve the specified path and set it as the current selection, returning
        // true or false based on success.  If the path is found, selection is set to Sticky.
        // If the UI is not ready, return false and pendingGeneration is true.
        internal bool SetSelectionPath(SelectionPath path, out bool pendingGeneration)
        {
            DependencyObject newSelection = SelectionPathResolver.ResolveSelectionPath(this, path, out pendingGeneration);

            if (newSelection != null)
            {
                SelectAndFocus(newSelection, StealFocusMode.OnlyIfCategoryListHasFocusWithin);
                this.SelectionMode = PropertySelectionMode.Sticky;
                return(true);
            }

            return(false);
        }
Exemple #3
0
        // Property Selection

        // <summary>
        // Sets the SelectionMode back to default.  This is a common enough
        // operation that it makes sense to abstract it to its own method.
        // </summary>
        private void ResetSelectionMode()
        {
            SelectionMode = PropertySelectionMode.Default;
        }