Ejemplo n.º 1
0
        private void InsertAndAnimate(int index, object item)
        {
            // insert
            InsertItem(index, item);
            if (canAnimate && EntranceAnimation != null && item != null)
            {
                var newContent = TreeHelper.FindChild(item.GetType(), innerItemsControl, index);
                if (newContent == null)
                {
                    // try to find ContentPresenter for item that is ViewModel
                    newContent = TreeHelper.FindChild <ContentPresenter>(innerItemsControl, index);
                }

                if (newContent is FrameworkElement newElement)
                {
                    EntranceAnimation.BeginAnimation(newElement, () =>
                    {
                        DequeueActionInternal();
                    });
                }
                else
                {
                    // TODO: throw/log ?
                    DequeueActionInternal();
                }
            }
            else
            {
                DequeueActionInternal();
            }
        }
Ejemplo n.º 2
0
        private void SetEntranceAnimationResource()
        {
            if (EntranceAnimation != null)
            {
                if (this.mainGrid.Resources.Contains(EntranceAnimation))
                {
                    this.mainGrid.Resources.Remove(EntranceAnimationStoryboardName);
                }

                var animationClone = EntranceAnimation.Clone();
                this.mainGrid.Resources[EntranceAnimationStoryboardName] = animationClone;
            }
        }