当前位置: 首页>>代码示例>>C#>>正文


C# Page.FindName方法代码示例

本文整理汇总了C#中System.Windows.Controls.Page.FindName方法的典型用法代码示例。如果您正苦于以下问题:C# Page.FindName方法的具体用法?C# Page.FindName怎么用?C# Page.FindName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.Page的用法示例。


在下文中一共展示了Page.FindName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadPage

 protected override void LoadPage(Page page)
 {
     if (page != null)
     {
        
         if (page.NavigationService != null)
             SelectedTabItem = PresentationUtility.GetLastTokenFromUri(page.NavigationService.CurrentSource);
      
         if (!string.IsNullOrEmpty(SelectedTabItem))
         {
             var tab = page.FindName(SelectedTabItem) as TabItem;
             if (tab != null)
             { 
                 LoadSelectedTab(tab);
                 PutFocusOnControl(tab);
             }
         }
         else
         {
             TabItem tab = GetdefaultTabItem(page);
             if(tab !=null)
             {
                 LoadSelectedTab(tab);
                 PutFocusOnControl(tab);
             }
             
         }
     }
 }
开发者ID:asanyaga,项目名称:BuildTest,代码行数:29,代码来源:OrderListingBaseViewModel.cs

示例2: UpdateControlState

        private void UpdateControlState(Page p1, string Tagname, string sControlType, string sControlName, string sPropertyName, int iValue, int pType, Tag t, bool bLogThisChange)
        {
            string sStatus = "";
            string sName = ""; //Used for error class
            bool bConfigError = false;
            bool bControlDoesntExist = false;

            MyObjectInfo moi = t.MyObject as MyObjectInfo;

            switch (sControlType)
            {
                #region Airlock_MPSN
                case "Airlock_MPSN":
                    p1.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                    {
                        try
                        {
                            var myAirlock_MPSN = (Airlock_MPSN)p1.FindName(sControlName);
                            if (myAirlock_MPSN == null) bControlDoesntExist = true;
                            if (sPropertyName == "MotorColor")
                            {
                                myAirlock_MPSN.MotorColor = iValue;
                                sStatus = myAirlock_MPSN.Status_Motor;
                                sName = myAirlock_MPSN.Name;
                                myAirlock_MPSN.Description_Motor = moi.TagName + " " + moi.TagDescription;
                                myAirlock_MPSN.ObjectNumber = moi.ObjectNo;
                                string sFaultString = moi.TagDescription + " (" + sStatus + ")";
                                bool bIsInFault = myAirlock_MPSN.Fault_Motor;
                                RegisterEvent(bIsInFault, sFaultString, moi.TagName, iValue, bLogThisChange);
                            }
                            else bConfigError = true;
                        }
                        catch (NullReferenceException)
                        {
                            AddError(new Error { ErrorTag = sControlName, ErrorSource = "Link Error", ErrorString = "Control " + sControlName + " does not exist on display page. Links exist in database. [" + Tagname + "]" });
                            btnErrors.Background = Brushes.Red;
                        }
                        catch (Exception ae)
                        {
                            AddError(new Error { ErrorTag = sControlName, ErrorSource = "Control Type", ErrorString = ae.Message });
                            btnErrors.Background = Brushes.Red;
                        }
                    }));
                    break;
                #endregion

                #region Airlock_MPSN_Cyclone
                case "Airlock_MPSN_Cyclone":
                    p1.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                    {
                        try
                        {
                            var myAirlock_MPSN_Cyclone = (Airlock_MPSN_Cyclone)p1.FindName(sControlName);
                            if (myAirlock_MPSN_Cyclone == null) bControlDoesntExist = true;
                            if (sPropertyName == "MotorColor")
                            {
                                myAirlock_MPSN_Cyclone.MotorColor = iValue;
                                sStatus = myAirlock_MPSN_Cyclone.Status_Motor;
                                sName = myAirlock_MPSN_Cyclone.Name;
                                myAirlock_MPSN_Cyclone.Description_Motor = moi.TagName + " " + moi.TagDescription;
                                myAirlock_MPSN_Cyclone.ObjectNumber = moi.ObjectNo;
                                string sFaultString = moi.TagDescription + " (" + sStatus + ")";
                                bool bIsInFault = myAirlock_MPSN_Cyclone.Fault_Motor;
                                RegisterEvent(bIsInFault, sFaultString, moi.TagName, iValue, bLogThisChange);
                            }
                            else bConfigError = true;
                        }
                        catch (NullReferenceException)
                        {
                            AddError(new Error { ErrorTag = sControlName, ErrorSource = "Link Error", ErrorString = "Control " + sControlName + " does not exist on display page. Links exist in database. [" + Tagname + "]" });
                            btnErrors.Background = Brushes.Red;
                        }
                        catch (Exception ae)
                        {
                            AddError(new Error { ErrorTag = sControlName, ErrorSource = "Control Type", ErrorString = ae.Message });
                            btnErrors.Background = Brushes.Red;
                        }
                    }));
                    break;
                #endregion

                #region AirValve1
                case "AirValve1":
                    p1.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                    {
                        try
                        {
                            var myAirValve1 = (AirValve1)p1.FindName(sControlName);
                            if (myAirValve1 == null) bControlDoesntExist = true;
                            if (sPropertyName == "ValveColor")
                            {
                                myAirValve1.ValveColor = iValue;
                                sStatus = myAirValve1.Status_Valve;
                                sName = myAirValve1.Name;
                                myAirValve1.Description_Valve = moi.TagName + " " + moi.TagDescription;
                                myAirValve1.ObjectNumber = moi.ObjectNo;
                                string sFaultString = moi.TagDescription + " (" + sStatus + ")";
                                bool bIsInFault = myAirValve1.Fault_Valve;
                                RegisterEvent(bIsInFault, sFaultString, moi.TagName, iValue, bLogThisChange);
                            }
//.........这里部分代码省略.........
开发者ID:HanrichPotgieter,项目名称:GBM_Vis,代码行数:101,代码来源:MainWindow.xaml.cs


注:本文中的System.Windows.Controls.Page.FindName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。