public SongsCollectionPage() { InitializeComponent(); ViewModel = DataContext as SecondaryPlaylistViewModel; SongsListView.Loaded += OnLoaded; AccentTitleTextBlock.GetVisual().Opacity = 0; SubtitleTextBlock.GetVisual().Opacity = 0; }
private void CoverImageOnImageProcessed(object sender, RoutedEventArgs routedEventArgs) { CoverImage.ImageProcessed -= CoverImageOnImageProcessed; var coverAnim = ConnectedAnimationService.GetForCurrentView().GetAnimation(ConnectedAnimationKeys.CoverTransition); coverAnim?.TryStart(CoverGrid); var titleAnim = ConnectedAnimationService.GetForCurrentView().GetAnimation(ConnectedAnimationKeys.TitleTransition); titleAnim?.TryStart(AccentTitleTextBlock); var subtitleAnim = ConnectedAnimationService.GetForCurrentView().GetAnimation(ConnectedAnimationKeys.SubtitleTransition); subtitleAnim?.TryStart(SubtitleTextBlock); CoverGrid.Opacity = 1; AccentTitleTextBlock.GetVisual().Opacity = 1; SubtitleTextBlock.GetVisual().Opacity = 1; }
private void SetupAnimations() { const float maxOffset = -16f; var scrollViewer = SongsListView.FindDescendant <ScrollViewer>(); var scrollerPropSet = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollViewer); var coverVisual = CoverGrid.GetVisual(); var coverPanelVisual = CoverPanel.GetVisual(); var titlePanelVisual = TitlePanel.GetVisual(); var contrastTitleTextVisual = ContrastTitleTextBlock.GetVisual(); var accentTitleTextVisual = AccentTitleTextBlock.GetVisual(); var subtitleTextVisual = SubtitleTextBlock.GetVisual(); var c = this.GetVisual().Compositor; var coverPanelCoordinateY = c.CreateExpressionAnimation("Clamp(scroller.Translation.Y * factor, -16, 0)"); coverPanelCoordinateY.SetReferenceParameter("scroller", scrollerPropSet); coverPanelCoordinateY.SetScalarParameter("factor", 0.2f); coverPanelVisual.StartAnimation("Offset.Y", coverPanelCoordinateY); var scaleAlgorithm = "Clamp(1 - layer.Offset.Y / maxOffset, 0.4, 1)"; var scaleAnim = c.CreateExpressionAnimation(scaleAlgorithm); scaleAnim.SetReferenceParameter("layer", coverPanelVisual); scaleAnim.SetScalarParameter("maxOffset", maxOffset); coverVisual.StartAnimation("Scale.X", scaleAnim); coverVisual.StartAnimation("Scale.Y", scaleAnim); var titlePanelCoordinateXAnim = c.CreateExpressionAnimation("coverOriginWidth * (layer.Scale.X - 1.0)"); titlePanelCoordinateXAnim.SetReferenceParameter("layer", coverVisual); titlePanelCoordinateXAnim.SetScalarParameter("coverOriginWidth", 76f); titlePanelVisual.StartAnimation("Offset.X", titlePanelCoordinateXAnim); var titlePanelCoordinateYAnim = c.CreateExpressionAnimation("layer.Offset.Y * 1.5"); titlePanelCoordinateYAnim.SetReferenceParameter("layer", coverPanelVisual); titlePanelVisual.StartAnimation("Offset.Y", titlePanelCoordinateYAnim); //var titleTextColorAnim = c.CreateExpressionAnimation("layer.Offset.Y < maxOffset / 2 ? whiteColor : accentColor"); //titleTextColorAnim.SetReferenceParameter("layer", coverPanelVisual); //titleTextColorAnim.SetScalarParameter("maxOffset", maxOffset); //titleTextColorAnim.SetColorParameter("whiteColor", Colors.White); //titleTextColorAnim.SetColorParameter("accentColor", ((SolidColorBrush)TitleTextBlock.Foreground).Color); var accentTitleOpacityAnim = c.CreateExpressionAnimation("1 - layer.Offset.Y / maxOffset"); accentTitleOpacityAnim.SetReferenceParameter("layer", coverPanelVisual); accentTitleOpacityAnim.SetScalarParameter("maxOffset", maxOffset); accentTitleTextVisual.StartAnimation("Opacity", accentTitleOpacityAnim); var contrastTitleOpcityAnim = c.CreateExpressionAnimation("layer.Offset.Y / maxOffset"); contrastTitleOpcityAnim.SetReferenceParameter("layer", coverPanelVisual); contrastTitleOpcityAnim.SetScalarParameter("maxOffset", maxOffset); contrastTitleTextVisual.StartAnimation("Opacity", contrastTitleOpcityAnim); var subtitleTextOpacityAnim = c.CreateExpressionAnimation("1 - layer.Offset.Y / maxOffset"); subtitleTextOpacityAnim.SetReferenceParameter("layer", coverPanelVisual); subtitleTextOpacityAnim.SetScalarParameter("maxOffset", maxOffset); subtitleTextVisual.StartAnimation("Opacity", subtitleTextOpacityAnim); }