<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                wpf中的控件模板里的元素有自己獨立的命名域。 因此不能通過FindName來根據x:Name來查找子節點。 自己寫了一個方法, 通過可視樹遍歷子節點,然后匹配名字。 如下: ~~~ private static ChildItem FindVisualChildItem<ChildItem>(DependencyObject obj) where ChildItem : DependencyObject { if (null != obj) { for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) { DependencyObject child = VisualTreeHelper.GetChild(obj, i); if (child != null && child is ChildItem) return (ChildItem)child; else { ChildItem childOfChild = FindVisualChildItem<ChildItem>(child); if (childOfChild != null) return childOfChild; } } } return null; } private static ChildItem FindVisualChildItem<ChildItem>(DependencyObject obj, string name) where ChildItem : FrameworkElement { if (null != obj) { for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) { DependencyObject child = VisualTreeHelper.GetChild(obj, i); if (child != null && child is ChildItem && (child as ChildItem).Name.Equals(name)) { return (ChildItem)child; } else { ChildItem childOfChild = FindVisualChildItem<ChildItem>(child, name); if (childOfChild != null && childOfChild is ChildItem && (childOfChild as ChildItem).Name.Equals(name)) { return childOfChild; } } } } return null; } ~~~ ~~~ ~~~ ~~~ ~~~ ~~~ 今天無意中發現系統FrameworkElement自帶了一個方法 ~~~ # [GetTemplateChild](http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&amp;l=EN-US&amp;k=k(SYSTEM.WINDOWS.FRAMEWORKELEMENT.GETTEMPLATECHILD);k(TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22);k(DevLang-CSHARP)&amp;rd=true)? 此方法同樣實現了根據名字來獲取控件模板里的子節點。 反編譯PresentaitionFramework,源碼如下: protected internal DependencyObject GetTemplateChild(string childName) { ? FrameworkTemplate templateInternal = this.TemplateInternal; ? if (templateInternal == null) ? { ? ? ? return null; ? } ? return StyleHelper.FindNameInTemplateContent(this, childName, templateInternal) as DependencyObject; } internal static object FindNameInTemplateContent(DependencyObject container, string childName, FrameworkTemplate frameworkTemplate) { ? int num = StyleHelper.QueryChildIndexFromChildName(childName, frameworkTemplate.ChildIndexFromChildName); ? if (num == -1) ? { ? ? ? Hashtable @value = StyleHelper.TemplatedNonFeChildrenField.GetValue(container); ? ? ? if (@value != null) ? ? ? { ? ? ? ? ? return @value[childName]; ? ? ? } ? } ? return null; ? return StyleHelper.GetChild(container, num); } 主要是childIndexFromChildName根據name來查詢index,然后根據index獲取對應子節點。?
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看