private void OnHeadersPanelHostDirectManipulationStarted(object sender, object e) { if (_isAnimating) { return; } _isScrolling = true; var header = TypedHeaders.Single(h => h.IsChecked == true); if (GetHeaderIndex(header) != SelectedIndex) { return; } var headerContainer = GetHeaderContainer(header); // _headersPanel goes over the its parent ScrollViewer's viewport, so we need to use it. var offsetX = headerContainer.RelativePosition(_headersPanel).X.ToFloat(); var offsetAnimation = _compositor.CreateExpressionAnimation($"CurrentOffsetX + {ScrollerTranslationX} + LeftMargin"); offsetAnimation.SetReferenceParameter(Scroller, _headersScrollingProperties); offsetAnimation.SetScalarParameter("LeftMargin", 12.0f); offsetAnimation.SetScalarParameter("CurrentOffsetX", offsetX); _selectedHeaderIndicatorVisual.StartAnimation("Offset.X", offsetAnimation); }
private void SyncUnderlineVisual() { var header = TypedHeaders.Single((h) => h.IsChecked == true); if (GetHeaderIndex(header) == SelectedIndex) { var textBlock = GetHeaderTextBlock(header); var offsetX = textBlock.OffsetX(_headersPanelHost); var scaleX = textBlock.ActualWidth.ToFloat(); // The ActualWidth of the HeaderUnderline Rectangle is 1 so I ignored the /1 here _underline.StartOffsetAnimation(AnimationAxis.X, null, offsetX, 400, easing: _compositor.EaseInOutCubic()); _underline.StartScaleAnimation(AnimationAxis.X, null, scaleX, 400, easing: _compositor.EaseInOutCubic()); } }
private void SyncSelectedHeaderIndicatorVisual() { var header = TypedHeaders.Single(h => h.IsChecked == true); if (GetHeaderIndex(header) != SelectedIndex) { return; } var container = GetHeaderContainer(header); var offsetX = container.RelativePosition(HeadersPanelHost).X.ToFloat() + 11.0f; // The ActualWidth of the selected header indication Rectangle is 1 so I ignored the /1 here. var scaleX = container.ActualWidth.ToFloat() - 24.0f; _selectedHeaderIndicatorVisual.StartOffsetAnimation(AnimationAxis.X, null, offsetX, 400, easing: _compositor.EaseInOutCubic()); _selectedHeaderIndicatorVisual.StartScaleAnimation(AnimationAxis.X, null, scaleX, 400, easing: _compositor.EaseInOutCubic()); }
private void SyncCheckedTabHeaderItem(int index) { var header = TypedHeaders.Single((h) => GetHeaderIndex(h) == index); header.IsChecked = true; }