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); }
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 += new EventHandler <EventArgs>(wrapper_Click); } wrapper.DataContext = wrapper.Content = content; parent.Children.Add(wrapper); // Need to do this before calling ApplyTemplate if (!reuse) { wrapper.ApplyTemplate(); } return(wrapper); }