Пример #1
0
        /// <summary>
        /// Updates the state of the visual.
        /// </summary>
        /// <param name="useTransitions">If set to <c>true</c> use transitions.</param>
        /// <remarks>The header will follow the parent <see cref="AccordionItem"/> states.</remarks>
        internal virtual void UpdateVisualState(bool useTransitions)
        {
            // the visualstate of the header is completely dependent on the parent state.
            if (this.ParentAccordionItem == null)
            {
                return;
            }

            if (this.ParentAccordionItem.IsSelected)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateExpanded);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateCollapsed);
            }

            switch (this.ParentAccordionItem.ExpandDirection)
            {
            // no animations on an expanddirection change.
            case ExpandDirection.Down:
                VisualStates.GoToState(this, false, VisualStates.StateExpandDown);
                break;

            case ExpandDirection.Up:
                VisualStates.GoToState(this, false, VisualStates.StateExpandUp);
                break;

            case ExpandDirection.Left:
                VisualStates.GoToState(this, false, VisualStates.StateExpandLeft);
                break;

            default:
                VisualStates.GoToState(this, false, VisualStates.StateExpandRight);
                break;
            }
        }