Ejemplo n.º 1
0
        /// <summary>
        /// Set appropriate visual state from MultiSelectStates group. (https://msdn.microsoft.com/en-us/library/windows/apps/mt299136.aspx?f=255&MSPPError=-2147217396)
        /// </summary>
        internal void ApplyMultiSelectState(bool isSelectionMultiple)
        {
            if (isSelectionMultiple)
            {
                // We can safely always go to multiselect state
                VisualStateManager.GoToState(this, "MultiSelectEnabled", useTransitions: true);
            }
            else
            {
                // Retrieve the current state (which 'lives' on the SelectorItem's template root, and may change if it is retemplated)
                var currentState = VisualStateManager.GetCurrentState(this, "MultiSelectStates")?.Name;

                if (currentState == "MultiSelectEnabled")
                {
                    // The MultiSelectDisabled state goes through VisibleRect then collapsed, which means Disabled state can't be
                    // invoked if the state is already disabled without having the selected check box appearing briefly. (Issue #403)
                    VisualStateManager.GoToState(this, "MultiSelectDisabled", useTransitions: true);
                }
            }
        }