Exemple #1
0
        /// <summary>
        /// 将用户控件添加到主界面的某个区域内

        /// </summary>
        /// <param name="panel">主界面的区域</param>
        /// <param name="userControlClassName">用户控件名</param>
        protected void NavigationToUserPage(Panel panel, string userControlClassName)
        {
            parentVisualPanel = panel;
            TransitionPresenter tp_Content = new TransitionPresenter();

            //parentVisualPanel.Children.Clear();
            foreach (UIElement u in parentVisualPanel.Children)
            {
                if (u.Uid == "tp_Content")
                {
                    HaveTp_Content = true;
                    tp_Content     = (TransitionPresenter)u;
                }
                //DoubleAnimation da = new DoubleAnimation(0d, new Duration(TimeSpan.FromMilliseconds(1000)));
                //u.BeginAnimation(OpacityProperty, da);
            }
            if (!HaveTp_Content)
            {
                tp_Content.Uid        = "tp_Content";
                tp_Content.RenderSize = new System.Windows.Size(panel.ActualWidth, panel.ActualHeight);
                parentVisualPanel.Children.Add(tp_Content);
            }

            //tp_Content.Transition = transitions[2];
            foreach (var item in transitions)
            {
                Transition transition = (Transition)item;
                if (TextSearch.GetText(transition) == transitionName.ToString())
                {
                    tp_Content.Transition = transition;
                }
            }

            foreach (var control in UserControlList)
            {
                if (control.GetType().FullName.ToString().Equals(userControlClassName))
                {
                    BaseUserControl userControl = (BaseUserControl)control;
                    da_Completed();
                    CurrentUserControl      = userControl;
                    CurrentUserControlName  = userControlClassName;
                    userControl.VisualPanel = parentVisualPanel;
                    tp_Content.Content      = userControl;
                    userControl.ShiftUI();                                          //每次执行切换界面必须执行这个函数
                }
            }
        }