private void UpdateLayoutInternal() { this.Width = NumberOfEntriesDisplayed * (100 + SpaceBetweenEntries) + SpaceBetweenEntries; this.Height = 100 + 2 * SpaceBetweenEntries; backgroundRectangle.Height = this.Height; backgroundRectangle.Width = this.Width; entryContainerClip.Clip = new RectangleGeometry(); (entryContainerClip.Clip as RectangleGeometry).Rect = new Rect(0, 0, this.Width - 20, this.Height - 20); Canvas.SetLeft(scrollRightButton, this.Width - 11); Canvas.SetLeft(refreshButton, (this.Width - refreshButton.Width) / 2); Canvas.SetTop(refreshButton, (this.Height - refreshButton.Height / 2)); Double _currLeft = 0; foreach (VideoPanelEntry entry in entryContainer.Children) { entry.ScrollHorizontallyTo(_currLeft); _currLeft += entry.Width + SpaceBetweenEntries; } if (LeftMostEntry == 0) { HideScrollLeftButtonStoryboard.Begin(); scrollLeftButton.IsHitTestVisible = false; } else { ShowScrollLeftButtonStoryboard.Begin(); scrollLeftButton.IsHitTestVisible = true; } if (LeftMostEntry + NumberOfEntriesDisplayed < entryContainer.Children.Count) { ShowScrollRightButtonStoryboard.Begin(); scrollRightButton.IsHitTestVisible = true; } else { HideScrollRightButtonStoryboard.Begin(); scrollRightButton.IsHitTestVisible = false; } Double _desiredLeftPosition = -LeftMostEntry * (100 + SpaceBetweenEntries); if (Canvas.GetLeft(entryContainer) != _desiredLeftPosition) { HorizontalScrollKeyFrame.Value = _desiredLeftPosition; HorizontalScrollStoryboard.Begin(); } }
public void ScrollHorizontallyTo(Double newPosition) { if (Canvas.GetLeft(this) == newPosition) { return; } if ((_isLoaded)) { HorizontalScrollStoryboard.Stop(); HorizontalScrollKeyFrame.Value = newPosition; HorizontalScrollStoryboard.Begin(); } else { Canvas.SetLeft(this, newPosition); } }