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 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); } } }