private void ContainerItem_Loaded(object sender, RoutedEventArgs e) { var itemsPanel = (ItemsWrapGrid)_samplePickerGridView.ItemsPanelRoot; var itemContainer = (GridViewItem)sender; itemContainer.Loaded -= this.ContainerItem_Loaded; var button = itemContainer.FindDescendant <Button>(); if (button != null) { button.Click -= MoreInfoClicked; button.Click += MoreInfoClicked; } if (!_isCreatorsUpdateOrAbove) { return; } var itemIndex = _samplePickerGridView.IndexFromContainer(itemContainer); var referenceIndex = itemsPanel.FirstVisibleIndex; if (_samplePickerGridView.SelectedIndex >= 0) { referenceIndex = _samplePickerGridView.SelectedIndex; } var relativeIndex = Math.Abs(itemIndex - referenceIndex); if (itemContainer.Content != CurrentSample && itemIndex >= 0 && itemIndex >= itemsPanel.FirstVisibleIndex && itemIndex <= itemsPanel.LastVisibleIndex) { var staggerDelay = TimeSpan.FromMilliseconds(relativeIndex * 30); var animationCollection = new AnimationCollection() { new OpacityAnimation() { From = 0, To = 1, Duration = TimeSpan.FromMilliseconds(400), Delay = staggerDelay, SetInitialValueBeforeDelay = true }, new ScaleAnimation() { From = "0.9", To = "1", Duration = TimeSpan.FromMilliseconds(400), Delay = staggerDelay } }; VisualExtensions.SetNormalizedCenterPoint(itemContainer, "0.5"); animationCollection.StartAnimation(itemContainer); } }
private void ContainerItem_Loaded(object sender, RoutedEventArgs e) { var itemsPanel = (ItemsWrapGrid)SamplePickerGridView.ItemsPanelRoot; var itemContainer = (GridViewItem)sender; itemContainer.Loaded -= this.ContainerItem_Loaded; var button = itemContainer.FindDescendant <Button>(); if (button != null) { button.Click -= MoreInfoClicked; button.LostFocus -= MoreInfoLostFocus; button.Click += MoreInfoClicked; button.LostFocus += MoreInfoLostFocus; } var itemIndex = SamplePickerGridView.IndexFromContainer(itemContainer); var referenceIndex = itemsPanel.FirstVisibleIndex; if (SamplePickerGridView.SelectedIndex >= 0) { referenceIndex = SamplePickerGridView.SelectedIndex; } var relativeIndex = Math.Abs(itemIndex - referenceIndex); if (itemContainer.Content != CurrentSample && itemIndex >= 0 && itemIndex >= itemsPanel.FirstVisibleIndex && itemIndex <= itemsPanel.LastVisibleIndex) { var staggerDelay = TimeSpan.FromMilliseconds(relativeIndex * 30); VisualExtensions.SetNormalizedCenterPoint(itemContainer, "0.5"); AnimationBuilder.Create() .Opacity(from: 0, to: 1, delay: staggerDelay) .Scale(from: 0.9, to: 1, delay: staggerDelay) .Start(itemContainer); } }