private void DownStyleChange(Label label)
 {
     if (label == null)
     {
         CollectionStack.SelectItem = CollectionSource.First();
     }
     else
     {
         int index = CollectionSource.ToList().IndexOf(label);
         if (index != CollectionSource.Count() - 1)
         {
             int offset = GetScrollViewerOffset();
             if (offset + 9 == index)
             {
                 SetScrollViewerOffset(offset + 1);
             }
             else if (offset > index || offset + 9 < index)
             {
                 SetScrollViewerOffset(index + 1);
             }
             StyleChange(label);
             CollectionStack.SelectItem = CollectionSource.ElementAt(index + 1);
         }
     }
 }
 private void SetPopup(Label label)
 {
     if (label != null)
     {
         int index    = CollectionSource.ToList().IndexOf(label);
         int offset   = GetScrollViewerOffset();
         int interval = index - offset;
         ItemPopup.PlacementTarget  = window;
         ItemPopup.Placement        = PlacementMode.Absolute;
         ItemPopup.HorizontalOffset = window.Left + 344;
         ItemPopup.VerticalOffset   = window.Top + 69 + interval * 20;
         SetPopupOpen(label);
     }
 }
 private void OnScrollChanged(object sender, ScrollChangedEventArgs e)
 {
     if (CollectionStack.SelectItem != null)
     {
         int offset   = GetScrollViewerOffset();
         int index    = CollectionSource.ToList().IndexOf(CollectionStack.SelectItem);
         int interval = index - offset;
         if (index >= offset && index <= offset + 9)
         {
             ItemPopup.VerticalOffset = window.Top + 69 + interval * 20;
         }
         else
         {
             RemovePopup();
         }
     }
 }
 private void UpStyleChange(Label label)
 {
     if (label != null)
     {
         int index = CollectionSource.ToList().IndexOf(label);
         if (index != 0)
         {
             int offset = GetScrollViewerOffset();
             if (offset == index)
             {
                 SetScrollViewerOffset(offset - 1);
             }
             else if (offset > index || offset + 9 < index)
             {
                 SetScrollViewerOffset(index - 1);
             }
             StyleChange(label);
             CollectionStack.SelectItem = CollectionSource.ElementAt(index - 1);
         }
     }
 }