private void Page_Loaded(object sender, RoutedEventArgs e) { clampTeacherCount.Translation = new Vector3(0, -100, 0); clampSendButton.Translation = new Vector3(0, -100, 0); var propSet = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollRoot); var compositor = propSet.Compositor; var props = compositor.CreatePropertySet(); props.InsertScalar("progress", 0); props.InsertScalar("clampSize", ClampBreakPoint); var propScroll = propSet.GetSpecializedReference <ManipulationPropertySetReferenceNode>(); var propGet = props.GetReference(); var progressionNode = propGet.GetScalarProperty("progress"); var clampSizeNode = propGet.GetScalarProperty("clampSize"); ExpressionNode progressAnim = ExpressionFunctions.Clamp(-propScroll.Translation.Y / clampSizeNode, 0, 1); props.StartAnimation("progress", progressAnim); ExpressionNode opacityNode = ExpressionFunctions.Lerp(0, 1, progressionNode); ElementCompositionPreview.GetElementVisual(fadeBlackHeader).StartAnimation("Opacity", opacityNode); }
private void Page_Loaded(object sender, RoutedEventArgs e) { var propSet = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollRoot); var compositor = propSet.Compositor; var props = compositor.CreatePropertySet(); props.InsertScalar("progress", 0); props.InsertScalar("clampSize", 150); var propScroll = propSet.GetSpecializedReference <ManipulationPropertySetReferenceNode>(); var propGet = props.GetReference(); var progressionNode = propGet.GetScalarProperty("progress"); var clampSizeNode = propGet.GetScalarProperty("clampSize"); ExpressionNode progressNode = ExpressionFunctions.Clamp(-propScroll.Translation.Y / clampSizeNode, 0, 1); props.StartAnimation("progress", progressNode); ExpressionNode opacityNode = ExpressionFunctions.Lerp(1, 0, progressionNode); var pnlDetailVisual = ElementCompositionPreview.GetElementVisual(pnlDetail); var pnlFeedbackForVisual = ElementCompositionPreview.GetElementVisual(pnlFeedbackFor); pnlDetailVisual.StartAnimation("Opacity", opacityNode); pnlFeedbackForVisual.StartAnimation("Opacity", opacityNode); ExpressionNode opacityInvertedNode = ExpressionFunctions.Lerp(0, 1, progressionNode); var headerBackgroundVisual = ElementCompositionPreview.GetElementVisual(recHeaderBackground); headerBackgroundVisual.StartAnimation("Opacity", opacityInvertedNode); ExpressionNode scaleNode = ExpressionFunctions.Lerp(1, 0, progressionNode / 2); var headerPSVisual = ElementCompositionPreview.GetElementVisual(headerPS); headerPSVisual.StartAnimation("Scale.X", scaleNode); headerPSVisual.StartAnimation("Scale.Y", scaleNode); ExpressionNode headerTextNode = ExpressionFunctions.Lerp(new Vector3(0, 0, 0), new Vector3(-50f, 0, 0), progressionNode); var pnlBasicInfoVisual = ElementCompositionPreview.GetElementVisual(pnlBasicInfo); pnlBasicInfoVisual.StartAnimation("Offset", headerTextNode); ExpressionNode actionButtonNode = ExpressionFunctions.Lerp(new Vector2(0, 0), new Vector2(0, 3.3f), progressionNode); var sendButtonViusal = ElementCompositionPreview.GetElementVisual(btnSend); sendButtonViusal.StartAnimation("AnchorPoint", actionButtonNode); }
private void OnPageLoaded(object sender, RoutedEventArgs e) { var animationService = ConnectedAnimationService.GetForCurrentView(); var animation = animationService.GetAnimation(Constants.ConnectedAnimationKey); if (animation != null) { animation.TryStart(CoverImage, new UIElement[] { SetImage }); } // Get the PropertySet that contains the scroll values from MyScrollViewer _scrollerPropertySet = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(MyScrollviewer); _compositor = _scrollerPropertySet.Compositor; // Create a PropertySet that has values to be referenced in the ExpressionAnimations below _props = _compositor.CreatePropertySet(); _props.InsertScalar("progress", 0); _props.InsertScalar("clampSize", 100); // Get references to our property sets for use with ExpressionNodes var scrollingProperties = _scrollerPropertySet.GetSpecializedReference <ManipulationPropertySetReferenceNode>(); var props = _props.GetReference(); var progressNode = props.GetScalarProperty("progress"); var clampSizeNode = props.GetScalarProperty("clampSize"); // Create and start an ExpressionAnimation to track scroll progress over the desired distance var progressAnimation = ExpressionFunctions.Clamp(-scrollingProperties.Translation.Y / clampSizeNode, 0, 1); _props.StartAnimation("progress", progressAnimation); // Get the backing visual for the header so that its properties can be animated var headerVisual = ElementCompositionPreview.GetElementVisual(Header); // Create and start an ExpressionAnimation to clamp the header's offset to keep it onscreen var headerTranslationAnimation = ExpressionFunctions.Conditional(progressNode < 1, 0, -scrollingProperties.Translation.Y - clampSizeNode); headerVisual.StartAnimation("Offset.Y", headerTranslationAnimation); // Create and start an ExpressionAnimation to scale the header during overpan var headerScaleAnimation = ExpressionFunctions.Lerp(1, 1.25f, ExpressionFunctions.Clamp(scrollingProperties.Translation.Y / 50, 0, 1)); headerVisual.StartAnimation("Scale.X", headerScaleAnimation); headerVisual.StartAnimation("Scale.Y", headerScaleAnimation); //Set the header's CenterPoint to ensure the overpan scale looks as desired headerVisual.CenterPoint = new Vector3((float)(Header.ActualWidth / 2), (float)Header.ActualHeight, 0); }
private void OnLoaded(object sender, RoutedEventArgs e) { var gridView = this.FindAscendant <GridView>(); if (gridView == null) { return; } var scrollViewer = gridView.FindDescendant <ScrollViewer>(); var headerPresenter = (UIElement)VisualTreeHelper.GetParent((UIElement)gridView.Header); var headerContainer = (UIElement)VisualTreeHelper.GetParent(headerPresenter); Canvas.SetZIndex(headerContainer, 1); _scrollerPropertySet = scrollViewer.GetScrollViewerManipulationPropertySet(); _compositor = _scrollerPropertySet.Compositor; _props = _compositor.CreatePropertySet(); _props.InsertScalar("progress", 0); _props.InsertScalar("clampSize", 240); _props.InsertScalar("scaleFactor", 0.7f); var scrollingProperties = _scrollerPropertySet.GetSpecializedReference <ManipulationPropertySetReferenceNode>(); var props = _props.GetReference(); var progressNode = props.GetScalarProperty("progress"); var clampSizeNode = props.GetScalarProperty("clampSize"); var scaleFactorNode = props.GetScalarProperty("scaleFactor"); ExpressionNode progressAnimation = ExpressionFunctions.Clamp(-scrollingProperties.Translation.Y / clampSizeNode, 0, 1); _props.StartAnimation("progress", progressAnimation); ExpressionNode headerScaleAnimation = ExpressionFunctions.Lerp(1, 1.25f, ExpressionFunctions.Clamp(scrollingProperties.Translation.Y / 50, 0, 1)); ExpressionNode headerTranslationAnimation = ExpressionFunctions.Conditional(progressNode < 1, 0, -scrollingProperties.Translation.Y - clampSizeNode); var headerVisual = this.ElementVisual(); headerVisual.CenterPoint = new Vector3((float)(this.ActualWidth / 2), (float)this.ActualHeight, 0); headerVisual.StartAnimation("Scale.X", headerScaleAnimation); headerVisual.StartAnimation("Scale.Y", headerScaleAnimation); headerVisual.StartAnimation("Offset.Y", headerTranslationAnimation); ExpressionNode primaryOpacityAnimation = 1 - progressNode; PrimaryBackground.ElementVisual().StartAnimation("opacity", primaryOpacityAnimation); ExpressionNode secondaryOpacityAnimation = progressNode; SecondaryBackground.ElementVisual().StartAnimation("opacity", secondaryOpacityAnimation); ExpressionNode scaleAnimation = ExpressionFunctions.Lerp(1, scaleFactorNode, progressNode); ExpressionNode opacityAnimation = ExpressionFunctions.Clamp(1 - (progressNode * 2), 0, 1); Visual autoSearchBoxVisual = SearchBox.ElementVisual(); autoSearchBoxVisual.CenterPoint = new Vector3((float)(SearchBox.ActualWidth / 2), (float)SearchBox.ActualHeight, 0); autoSearchBoxVisual.StartAnimation("Scale.X", scaleAnimation); autoSearchBoxVisual.StartAnimation("Scale.Y", scaleAnimation); autoSearchBoxVisual.StartAnimation("Opacity", opacityAnimation); Visual subMenuPanelVisual = SubMenuPanel.ElementVisual(); ExpressionNode contentOffsetAnimation = progressNode * 100; subMenuPanelVisual.StartAnimation("Offset.Y", contentOffsetAnimation); ExpressionNode searchBtnOpacityAnimation = ExpressionFunctions.Conditional(progressNode < 1, 0, 1); Visual searchBtnVisual = ElementCompositionPreview.GetElementVisual(SearchBtn); searchBtnVisual.StartAnimation("Opacity", searchBtnOpacityAnimation); }
private void InitializeExpressionAnimations() { try { // Get the PropertySet that contains the scroll values from MyScrollViewer var scrollerPropertySet = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(AccountScrollViewer); var compositor = scrollerPropertySet.Compositor; // Create a PropertySet that has values to be referenced in the ExpressionAnimations below var props = compositor.CreatePropertySet(); props.InsertScalar("progress", 0); props.InsertScalar("clampSize", 88); props.InsertScalar("scaleFactor", 0.3f); // Get references to our property sets for use with ExpressionNodes var scrollingProperties = scrollerPropertySet.GetSpecializedReference <ManipulationPropertySetReferenceNode>(); var properties = props.GetReference(); var progressNode = properties.GetScalarProperty("progress"); var clampSizeNode = properties.GetScalarProperty("clampSize"); var scaleFactorNode = properties.GetScalarProperty("scaleFactor"); // Create and start an ExpressionAnimation to track scroll progress over the desired distance var progressAnimation = ExpressionFunctions.Clamp(-scrollingProperties.Translation.Y / clampSizeNode, 0, 1); props.StartAnimation("progress", progressAnimation); // *** Scaling the header grid *** // Get the backing visual for the header so that its properties can be animated var headerVisual = ElementCompositionPreview.GetElementVisual(Header); // Create and start an ExpressionAnimation to clamp the header's offset to keep it onscreen var headerTranslationAnimation = ExpressionFunctions.Conditional(progressNode < 1, 0, -scrollingProperties.Translation.Y - clampSizeNode); headerVisual.StartAnimation("Offset.Y", headerTranslationAnimation); // Create and start an ExpressionAnimation to scale the header during overpan var headerScaleAnimation = ExpressionFunctions.Lerp(1, 1.25f, ExpressionFunctions.Clamp(scrollingProperties.Translation.Y / 50, 0, 1)); headerVisual.StartAnimation("Scale.X", headerScaleAnimation); headerVisual.StartAnimation("Scale.Y", headerScaleAnimation); //Set the header's CenterPoint to ensure the overpan scale looks as desired headerVisual.CenterPoint = new Vector3((float)(Header.ActualWidth / 2), (float)Header.ActualHeight, 0); // *** Animating the account logo *** // Get the backing visual for the account logo visual so that its properties can be animated var accountLogoVisual = ElementCompositionPreview.GetElementVisual(HeaderAccountLogo); // Create and start an ExpressionAnimation to scale the account logo with scroll position var accountLogoScaleAnimation = ExpressionFunctions.Lerp(1, scaleFactorNode, progressNode); accountLogoVisual.StartAnimation("Scale.X", accountLogoScaleAnimation); accountLogoVisual.StartAnimation("Scale.Y", accountLogoScaleAnimation); // *** Animating the title *** // Get the backing visual for the title visual so that its properties can be animated var titleVisual = ElementCompositionPreview.GetElementVisual(HeaderTitle); // Create and start an ExpressionAnimation to scale the title with scroll position var titleOffsetAnimation = progressNode * -88; titleVisual.StartAnimation("Offset.X", titleOffsetAnimation); // *** Animating the subtitle *** // Get the backing visual for the subtitle visual so that its properties can be animated var subtitleVisual = ElementCompositionPreview.GetElementVisual(HeaderSubtitle); // Create and start an ExpressionAnimation to scale the subtitle with scroll position var subtitleScaleAnimation = ExpressionFunctions.Lerp(1, scaleFactorNode, progressNode); subtitleVisual.StartAnimation("Scale.X", subtitleScaleAnimation); subtitleVisual.StartAnimation("Scale.Y", subtitleScaleAnimation); // Create an ExpressionAnimation that moves between 1 and 0 with scroll progress, to be used for subtitle opacity var subtitleOpacityAnimation = ExpressionFunctions.Clamp(1 - (progressNode * 2), 0, 1); subtitleVisual.StartAnimation("Opacity", subtitleOpacityAnimation); // *** Animating the editable subtitle *** // Get the backing visual for the subtitle visual so that its properties can be animated var editableSubtitleVisual = ElementCompositionPreview.GetElementVisual(HeaderEditableSubtitle); // Create and start an ExpressionAnimation to scale the subtitle with scroll position var editableSubtitleScaleAnimation = ExpressionFunctions.Lerp(1, scaleFactorNode, progressNode); editableSubtitleVisual.StartAnimation("Scale.X", editableSubtitleScaleAnimation); editableSubtitleVisual.StartAnimation("Scale.Y", editableSubtitleScaleAnimation); // Create an ExpressionAnimation that moves between 1 and 0 with scroll progress, to be used for subtitle opacity var editableSubtitleOpacityAnimation = ExpressionFunctions.Clamp(1 - (progressNode * 2), 0, 1); editableSubtitleVisual.StartAnimation("Opacity", editableSubtitleOpacityAnimation); // *** Animating the buttons bar *** // Get the backing visual for the buttons bar visual so that its properties can be animated var buttonsBarVisual = ElementCompositionPreview.GetElementVisual(HeaderButtonsBar); // Create and start an ExpressionAnimation to scale the buttons bar with scroll position var buttonsBarOffsetAnimation = progressNode * -88; buttonsBarVisual.StartAnimation("Offset.Y", buttonsBarOffsetAnimation); // Create an ExpressionAnimation that moves between 1 and 0 with scroll progress, to be used for buttons bar opacity var buttonsBarOpacityAnimation = ExpressionFunctions.Clamp(1 - (progressNode * 2), 0, 1); buttonsBarVisual.StartAnimation("Opacity", buttonsBarOpacityAnimation); // *** Animating the header content *** // Get the backing visual for the header content visual so that its properties can be animated var headerContentVisual = ElementCompositionPreview.GetElementVisual(HeaderContent); // When the header stops scrolling it is 88 pixels offscreen. We want the text header to end up with 24 pixels of its content // offscreen which means it needs to go from offset 0 to 88 as we traverse through the scrollable region var headerContentOffsetAnimation = progressNode * 88; headerContentVisual.StartAnimation("Offset.Y", headerContentOffsetAnimation); } catch { } }
private void MainInformationPage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e) { ApplicationViewTitleBar formattableTitleBar = ApplicationView.GetForCurrentView().TitleBar; formattableTitleBar.ButtonBackgroundColor = Colors.Transparent; formattableTitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar; coreTitleBar.ExtendViewIntoTitleBar = true; // Update the ZIndex of the header container so that the header is above the items when scrolling Canvas.SetZIndex(Header, 1); // Get the PropertySet that contains the scroll values from the ScrollViewer _scrollerPropertySet = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollViewer); _compositor = _scrollerPropertySet.Compositor; // Create a PropertySet that has values to be referenced in the ExpressionAnimations below _props = _compositor.CreatePropertySet(); _props.InsertScalar("progress", 0); _props.InsertScalar("clampSize", 150); _props.InsertScalar("scaleFactor", 0.7f); // Get references to our property sets for use with ExpressionNodes var scrollingProperties = _scrollerPropertySet.GetSpecializedReference <ManipulationPropertySetReferenceNode>(); var props = _props.GetReference(); var progressNode = props.GetScalarProperty("progress"); var clampSizeNode = props.GetScalarProperty("clampSize"); // Create and start an ExpressionAnimation to track scroll progress over the desired distance ExpressionNode progressAnimation = ExpressionFunctions.Clamp(-scrollingProperties.Translation.Y / clampSizeNode, 0, 1); _props.StartAnimation("progress", progressAnimation); // Get the backing visual for the header so that its properties can be animated headerVisual = ElementCompositionPreview.GetElementVisual(Header); // Create and start an ExpressionAnimation to clamp the header's offset to keep it onscreen ExpressionNode headerTranslationAnimation = ExpressionFunctions.Conditional(progressNode < 1, 0, -scrollingProperties.Translation.Y - clampSizeNode); headerVisual.StartAnimation("Offset.Y", headerTranslationAnimation); // Create and start an ExpressionAnimation to scale the header during overpan ExpressionNode headerScaleAnimation = ExpressionFunctions.Lerp(1, 1.25f, ExpressionFunctions.Clamp(scrollingProperties.Translation.Y / 50, 0, 1)); headerVisual.StartAnimation("Scale.X", headerScaleAnimation); headerVisual.StartAnimation("Scale.Y", headerScaleAnimation); //Set the header's CenterPoint to ensure the overpan scale looks as desired headerVisual.CenterPoint = new Vector3((float)(Header.ActualWidth / 2), (float)Header.ActualHeight, 0); ExpressionNode OpacityAnimation = ExpressionFunctions.Clamp(1 - (progressNode * 2), 0, 1); Visual profileVisual = ElementCompositionPreview.GetElementVisual(ProfileImage); profileVisual.StartAnimation("Opacity", OpacityAnimation); Visual subtitleVisual = ElementCompositionPreview.GetElementVisual(SubtitleBlock); subtitleVisual.StartAnimation("Opacity", OpacityAnimation); // Get the backing visuals for the text and button containers so that their properites can be animated Visual buttonVisual = ElementCompositionPreview.GetElementVisual(ButtonPanel); ExpressionNode buttonOffsetAnimation = progressNode * -14; buttonVisual.StartAnimation("Offset.Y", buttonOffsetAnimation); }