Esempio n. 1
0
        private void ItemContainer_Loaded(object sender, RoutedEventArgs e)
        {
            var itemsPanel    = (ItemsWrapGrid)GRIDVWcode.ItemsPanelRoot;
            var itemContainer = (GridViewItem)sender;
            var txt           = GetRichTextBlock(itemContainer);
            var itemIndex     = GRIDVWcode.IndexFromContainer(itemContainer);
            var p             = codeList[itemIndex].RichTextCode;

            if (p == null)
            {
                TextBlock rtxt = GetTextBlock(itemContainer);
                if (rtxt != null)
                {
                    rtxt.Opacity    = 1;
                    rtxt.Visibility = Visibility.Visible;
                    txt.Opacity     = 0;
                }
            }
            else
            {
                txt.Blocks.Add(p);
            }

            if (itemIndex >= itemsPanel.FirstVisibleIndex && itemIndex <= itemsPanel.LastVisibleIndex)
            {
                var itemVisual = itemContainer.GetVisual();
                var delayIndex = itemIndex - itemsPanel.FirstVisibleIndex;

                itemVisual.Opacity = 0f;
                itemVisual.SetTranslation(new Vector3(50, 0, 0));

                // Create KeyFrameAnimations
                var offsetAnimation = _compositor.CreateScalarKeyFrameAnimation();
                offsetAnimation.InsertKeyFrame(1f, 0f);
                offsetAnimation.Duration  = TimeSpan.FromMilliseconds(700);
                offsetAnimation.DelayTime = TimeSpan.FromMilliseconds((delayIndex * 30));

                var fadeAnimation = _compositor.CreateScalarKeyFrameAnimation();
                fadeAnimation.InsertKeyFrame(1f, 1f);
                fadeAnimation.Duration  = TimeSpan.FromMilliseconds(700);
                fadeAnimation.DelayTime = TimeSpan.FromMilliseconds(delayIndex * 30);

                // Start animations
                itemVisual.StartAnimation(itemVisual.GetTranslationXPropertyName(), offsetAnimation);
                itemVisual.StartAnimation("Opacity", fadeAnimation);
            }
            itemContainer.Loaded -= ItemContainer_Loaded;
        }
Esempio n. 2
0
 public SearchResultPage()
 {
     this.InitializeComponent();
     this._compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
     this._listVisual = GRIDVWcode.GetVisual();
 }