Microsoft.Phone.Controls.Primitives.LoopingSelectorItem.SetState C# (CSharp) Метод

SetState() приватный Метод

Put this item into a new state.
private SetState ( State newState, bool useTransitions ) : void
newState State The new state.
useTransitions bool Flag indicating that transitions should be used when going to the new state.
Результат void
        internal void SetState(State newState, bool useTransitions)
        {
            _state = newState;
            switch (_state)
            {
                case State.Normal:
                    VisualStateManager.GoToState(this, NormalStateName, useTransitions);
                    break;
                case State.Expanded:
                    VisualStateManager.GoToState(this, ExpandedStateName, useTransitions);
                    break;
                case State.Selected:
                    VisualStateManager.GoToState(this, SelectedStateName, useTransitions);
                    break;
            }
        }

Usage Example

Пример #1
0
        private LoopingSelectorItem CreateAndAddItem(Panel parent, object content)
        {
            bool reuse = _temporaryItemsPool != null && _temporaryItemsPool.Count > 0;

            LoopingSelectorItem wrapper = reuse ? _temporaryItemsPool.Dequeue() : new LoopingSelectorItem();

            if (!reuse)
            {
                wrapper.ContentTemplate = this.ItemTemplate;
                wrapper.Width           = ItemSize.Width;
                wrapper.Height          = ItemSize.Height;
                wrapper.Padding         = ItemMargin;

                wrapper.Click += OnWrapperClick;
            }

            wrapper.DataContext = wrapper.Content = content;

            parent.Children.Add(wrapper); // Need to do this before calling ApplyTemplate
            if (!reuse)
            {
                wrapper.ApplyTemplate();
                wrapper.SetState(LoopingSelectorItem.State.Normal, false);
            }

            // Item should be visible if this control is expanded.
            if (IsExpanded)
            {
                // Uses transitions only when going from normal to expanded state.
                wrapper.SetState(LoopingSelectorItem.State.Expanded, !_actualIsExpanded);
            }

            return(wrapper);
        }
All Usage Examples Of Microsoft.Phone.Controls.Primitives.LoopingSelectorItem::SetState