Пример #1
0
        /// <summary>
        /// Registers an element (part of a DataTemplate in a list control)
        /// with the ConnectedAnimations service to run automatically on page navigation
        /// </summary>
        /// <param name="page">The parent page of the list control</param>
        /// <param name="listViewBase">The list control (such as ListView or GridView)</param>
        /// <param name="key">The key of the element (same key will need to be used on another page)</param>
        /// <param name="elementName">The name of the element in the DataTemplate that should be animated</param>
        public static void RegisterListItemForConnectedAnimation(this Page page, ListViewBase listViewBase, string key, string elementName)
        {
            if (listViewBase == null || string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(elementName))
            {
                return;
            }

            var props = GetPageConnectedAnimationProperties(page);

            if (!props.TryGetValue(key, out var prop))
            {
                prop = new ConnectedAnimationProperties
                {
                    Key = key,
                    ListAnimProperties = new List <ConnectedAnimationListProperty>()
                };
                props[key] = prop;
            }

            if (!prop.ListAnimProperties.Any(lap => lap.ListViewBase == listViewBase && lap.ElementName == elementName))
            {
                prop.ListAnimProperties.Add(new ConnectedAnimationListProperty
                {
                    ElementName  = elementName,
                    ListViewBase = listViewBase
                });
            }
        }
        /// <summary>
        /// Registers an element with the given key with the <see cref="ConnectedAnimationService"/>
        /// </summary>
        /// <param name="key">The key to be used with the <see cref="ConnectedAnimationService"/></param>
        /// <param name="element">The element to be animated</param>
        public void RegisterKey(string key, UIElement element)
        {
            if (key != null)
            {
                var animation = new ConnectedAnimationProperties()
                {
                    Key     = key,
                    Element = element,
                };

                _connectedAnimationsProps[key] = animation;
            }
        }
Пример #3
0
        private static void RegisterKey(this Page page, string key, UIElement element)
        {
            if (key != null)
            {
                var animation = new ConnectedAnimationProperties()
                {
                    Key     = key,
                    Element = element,
                };

                var props = GetPageConnectedAnimationProperties(page);
                props[key] = animation;
            }
        }
        /// <summary>
        /// Registers the ListViewBase element items to participate in a connected animation
        /// When page is navigated, the parameter used in the navigation is used to decide
        /// which item to animate
        /// </summary>
        /// <param name="listViewBase">The <see cref="ListViewBase"/></param>
        /// <param name="key">The connected animation key to register with the <see cref="ConnectedAnimationService"/></param>
        /// <param name="elementName">The name of the element in the <see cref="DataTemplate"/> to animate</param>
        public void RegisterListItem(ListViewBase listViewBase, string key, string elementName)
        {
            if (listViewBase == null || string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(elementName))
            {
                return;
            }

            var props = new ConnectedAnimationProperties()
            {
                Key             = key,
                IsListAnimation = true,
                ElementName     = elementName,
                ListViewBase    = listViewBase
            };

            _connectedAnimationsProps[key] = props;
        }
Пример #5
0
        private static void RegisterListItem(this Page page, Windows.UI.Xaml.Controls.ListViewBase listViewBase, string key, string elementName)
        {
            if (listViewBase == null || string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(elementName))
            {
                return;
            }

            var prop = new ConnectedAnimationProperties()
            {
                Key             = key,
                IsListAnimation = true,
                ElementName     = elementName,
                ListViewBase    = listViewBase
            };

            var props = GetPageConnectedAnimationProperties(page);

            props[key] = prop;
        }
Пример #6
0
        /// <summary>
        /// Registers an <see cref="UIElement"/> with the ConnectedAnimations service to run automatically on page navigation
        /// </summary>
        /// <param name="page">The parent page of the element</param>
        /// <param name="key">The key of the element (same key will need to be used on another page)</param>
        /// <param name="element">The element to animate</param>
        /// <param name="anchors">Any other elements to animate alongside the element</param>
        public static void RegisterElementForConnectedAnimation(this Page page, string key, UIElement element, IEnumerable <UIElement> anchors = null)
        {
            if (key != null && element != null)
            {
                var animation = new ConnectedAnimationProperties()
                {
                    Key     = key,
                    Element = element,
                };

                var props = GetPageConnectedAnimationProperties(page);
                props[key] = animation;

                if (anchors != null)
                {
                    foreach (var anchor in anchors)
                    {
                        page.AttachAnchorElementForConnectedAnimation(element, anchor);
                    }
                }
            }
        }