Exemple #1
0
 protected override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     for (var i = 0; i < ItemContainerTransitions.Count; i++)
     {
         if (ItemContainerTransitions[i] is EntranceThemeTransition)
         {
             ItemContainerTransitions.RemoveAt(i);
         }
     }
 }
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            // Remove the entrance animation on the item containers.
            for (int i = 0; i < ItemContainerTransitions.Count; i++)
            {
                if (ItemContainerTransitions[i] is EntranceThemeTransition)
                {
                    ItemContainerTransitions.RemoveAt(i);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AdaptiveGridView"/> class.
        /// </summary>
        public AdaptiveGridView()
        {
            IsTabStop    = false;
            SizeChanged += OnSizeChanged;
            ItemClick   += OnItemClick;
            if (Items != null)
            {
                Items.VectorChanged += ItemsOnVectorChanged;
            }
            Loaded   += OnLoaded;
            Unloaded += OnUnloaded;

            // Define ItemContainerStyle in code rather than using the DefaultStyle
            // to avoid having to define the entire style of a GridView. This can still
            // be set by the enduser to values of their chosing
            var style = new Style(typeof(GridViewItem));

            style.Setters.Add(new Setter(HorizontalContentAlignmentProperty, HorizontalAlignment.Stretch));
            style.Setters.Add(new Setter(VerticalContentAlignmentProperty, VerticalAlignment.Stretch));
            ItemContainerStyle = style;

            // Set up opacity and scale animations.
            var compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

            _scaleAnimation          = compositor.CreateVector3KeyFrameAnimation();
            _scaleAnimation.Duration = TimeSpan.FromMilliseconds(AnimationDuration);
            _scaleAnimation.InsertKeyFrame(0, new Vector3(0.8f, 0.8f, 0));
            _scaleAnimation.InsertKeyFrame(1, Vector3.One, EaseOutCubic(compositor));
            _opacityAnimation          = compositor.CreateScalarKeyFrameAnimation();
            _opacityAnimation.Duration = TimeSpan.FromMilliseconds(AnimationDuration);
            _opacityAnimation.InsertKeyFrame(1, 1.0f, EaseOutCubic(compositor));

            // Remove the default entrance transition if existed.
            RegisterPropertyChangedCallback(ItemContainerTransitionsProperty, (s, e) =>
            {
                var entranceThemeTransition = ItemContainerTransitions.OfType <EntranceThemeTransition>().SingleOrDefault();
                if (entranceThemeTransition != null)
                {
                    ItemContainerTransitions.Remove(entranceThemeTransition);
                }
            });
        }