protected override FrameworkElement ModifyNewContent(ITransitionControl container, FrameworkElement newContent)
        {
            if (newContent == null)
            {
                HideBackground(container);
                container.Remove(_border);
                return null;
            }

            ShowBackground(container);

            _border = WrapInBorder(newContent);

            _border.Opacity = 0;

            SetPosition(_border);

            newContent.SizeChanged += (sender, e) => SetPosition(_border);

            var ctrl = container.AsControl();

            ctrl.SizeChanged += (sender, e) => SetPosition(_border);

            return _border;
        }
        public void Transition(ITransitionControl container, FrameworkElement oldContent, FrameworkElement newContent)
        {
            FrameworkElement newContentToAdd = ModifyNewContent(container, newContent);

            container.Add(newContentToAdd);

            if (oldContent != null)
            {
                GetOutAnimation()
                    .UponCompletion(() => container.Remove(oldContent))
                    .AnimateOn(oldContent);
            }

            if (newContentToAdd != null)
            {
                GetInAnimation()
                    .AnimateOn(newContentToAdd);
            }
        }
 void HideBackground(ITransitionControl container)
 {
     if (container.Contains(_background))
     {
         Animate.The(UIElement.OpacityProperty)
             .From(1d)
             .To(0d)
             .For(_duration)
             .UponCompletion(() => container.Remove(_background))
             .Create()
             .AnimateOn(_background);
     }
 }