コード例 #1
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            ContentPresentationSite = GetTemplateChild(ContentPresentationSiteName) as ContentPresenter;

            StoryboardLeftIn = FindResource(ContentLeftInName) as Storyboard;
            if (StoryboardLeftIn != null)
            {
                if (StoryboardLeftIn.IsFrozen)
                {
                    StoryboardLeftIn            = StoryboardLeftIn.Clone();
                    StoryboardLeftIn.Completed += OnTransitionCompleted;
                }
            }

            StoryboardLeftOut = FindResource(ContentLeftOutName) as Storyboard;
            if (StoryboardLeftOut != null)
            {
                if (StoryboardLeftOut.IsFrozen)
                {
                    StoryboardLeftOut            = StoryboardLeftOut.Clone();
                    StoryboardLeftOut.Completed += OnTransitionCompleted;
                }
            }

            StoryboardRightIn = FindResource(ContentRightInName) as Storyboard;
            if (StoryboardRightIn != null)
            {
                if (StoryboardRightIn.IsFrozen)
                {
                    StoryboardRightIn            = StoryboardRightIn.Clone();
                    StoryboardRightIn.Completed += OnTransitionCompleted;
                }
            }

            StoryboardRightOut = FindResource(ContentRightOutName) as Storyboard;
            if (StoryboardRightOut != null)
            {
                if (StoryboardRightOut.IsFrozen)
                {
                    StoryboardRightOut            = StoryboardRightOut.Clone();
                    StoryboardRightOut.Completed += OnTransitionCompleted;
                }
            }

            if (ContentPresentationSite != null)
            {
                ContentPresentationSite.Content = Content;
            }

            //VisualStateManager.GoToState(this, NormalName, true);
        }
コード例 #2
0
        public void ChangeContent(object content, PathContentTranstitionType tranType, Action callBack = null)
        {
            _ComplateCallBack = callBack;
            switch (tranType)
            {
            case PathContentTranstitionType.LEFT_IN:
                this.Content = content;
                if (StoryboardLeftIn != null)
                {
                    StoryboardLeftIn.Begin(this.ContentPresentationSite);
                }
                break;

            case PathContentTranstitionType.LEFT_OUT:
                nextContext = content;
                if (StoryboardLeftOut != null)
                {
                    StoryboardLeftOut.Begin(this.ContentPresentationSite);
                }
                break;

            case PathContentTranstitionType.RIGHT_IN:
                this.Content = content;
                if (StoryboardRightIn != null)
                {
                    StoryboardRightIn.Begin(this.ContentPresentationSite);
                }
                break;

            case PathContentTranstitionType.RIGHT_OUT:
                nextContext = content;
                if (StoryboardRightOut != null)
                {
                    StoryboardRightOut.Begin(this.ContentPresentationSite);
                }
                break;

            default:
                this.Content = content;
                break;
            }
        }