private async Task UpdateStoryboard() { if (_updating) { return; } _updating = true; IsHitTestVisible = false; await Task.Yield(); var widthAnimation = AnimateX(GetDynamicCategoriesWidth(), ColumnFirst.Width); ColumnFirst.BeginAnimation(WidthProperty, widthAnimation); if (Model.LayoutPhase > 0 && CategoriesList.GetItemVisual(Model.SelectedCategory) is FrameworkElement element) { var transform = element.TransformToVisual(CategoriesList); var positionInScrollViewer = transform.Transform(new Point(0, 0)); CategoriesScroll.BeginAnimation(AnimatableScrollViewer.CustomHorizontalOffsetProperty, AnimateX(positionInScrollViewer.X - (GetCategoriesColumns() - 1d) * GetCategoriesItemSize() / 2d, CategoriesScroll.CustomHorizontalOffset, duration: widthAnimation.Duration.TimeSpan.TotalSeconds)); } ColumnSecond.BeginAnimation(WidthProperty, AnimateX(GetDynamicItemsWidth(), ColumnSecond.Width)); TransformSecond.BeginAnimation(TranslateTransform.XProperty, AnimateX(GetDynamicItemsOffset(), TransformSecond.X)); TransformThird.BeginAnimation(TranslateTransform.XProperty, AnimateX(GetDynamicSelectedOffset(), TransformThird.X)); _updating = false; await Task.Delay(200); IsHitTestVisible = true; }
private void UpdateColumnsLayout() { if (_lastWidth != ActualWidth) { _lastWidth = ActualWidth; var categoryMaxRows = Math.Floor(ActualHeight / 106d); var categoryColumns = Math.Ceiling(_categories.Count / categoryMaxRows); if (categoryColumns < categoryMaxRows) { ColumnFirst.MaxHeight = 20d + 106d * Math.Ceiling(Math.Sqrt(_categories.Count)); } ColumnFirst.BeginAnimation(WidthProperty, null); ColumnFirst.Width = GetDynamicCategoriesWidth(); CategoriesScroll.BeginAnimation(AnimatableScrollViewer.CustomHorizontalOffsetProperty, null); if (Model.LayoutPhase > 0) { CategoriesList.ScrollIntoView(CategoriesList.SelectedItem); } ColumnSecond.BeginAnimation(WidthProperty, null); TransformSecond.BeginAnimation(TranslateTransform.XProperty, null); ColumnSecond.Width = GetDynamicItemsWidth(); TransformSecond.X = GetDynamicItemsOffset(); TransformThird.BeginAnimation(TranslateTransform.XProperty, null); ColumnThird.Width = _lastWidth - GetCategoriesCompactWidth() - GetItemsCompactWidth(); TransformThird.X = GetDynamicSelectedOffset(); } }
private void UpdateColumnsLayout() { if (_lastWidth != ActualWidth) { _lastWidth = ActualWidth; _sectionSize = _lastWidth / 3d; ColumnFirst.Width = _sectionSize; ColumnSecond.Width = _sectionSize; ColumnThird.Width = _sectionSize; TransformFirst.BeginAnimation(TranslateTransform.XProperty, null); TransformSecond.BeginAnimation(TranslateTransform.XProperty, null); TransformThird.BeginAnimation(TranslateTransform.XProperty, null); TransformFirst.X = GetTranslateX(0); TransformSecond.X = GetTranslateX(1); TransformThird.X = GetTranslateX(2); } }
private async Task UpdateStoryboard() { if (_updating) { return; } _updating = true; IsHitTestVisible = false; await Task.Yield(); TransformFirst.BeginAnimation(TranslateTransform.XProperty, AnimateX(GetTranslateX(0))); TransformSecond.BeginAnimation(TranslateTransform.XProperty, AnimateX(GetTranslateX(1))); TransformThird.BeginAnimation(TranslateTransform.XProperty, AnimateX(GetTranslateX(2))); _updating = false; await Task.Delay(200); IsHitTestVisible = true; }