internal static void AddLogicalChild(FrameworkElement parentFE, FrameworkContentElement parentFCE, object child) { if (child != null) { if (parentFE != null) { parentFE.AddLogicalChild(child); } else if (parentFCE != null) { parentFCE.AddLogicalChild(child); } } }
// Token: 0x06000769 RID: 1897 RVA: 0x000172A8 File Offset: 0x000154A8 internal static void AddLogicalChild(DependencyObject parent, object child) { if (child != null && parent != null) { FrameworkElement frameworkElement = parent as FrameworkElement; if (frameworkElement != null) { frameworkElement.AddLogicalChild(child); return; } FrameworkContentElement frameworkContentElement = parent as FrameworkContentElement; if (frameworkContentElement != null) { frameworkContentElement.AddLogicalChild(child); } } }
/* * /// <summary> * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #endregion Public Methods //------------------------------------------------------ // // Public Events // //------------------------------------------------------ // None //------------------------------------------------------ // // Internal Constructors // //------------------------------------------------------ // None //------------------------------------------------------ // // Internal Properties // //------------------------------------------------------ // None //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods internal static void AddLogicalChild(DependencyObject parent, object child) { if (child != null && parent != null) { FrameworkElement parentFE = parent as FrameworkElement; if (parentFE != null) { parentFE.AddLogicalChild(child); } else { FrameworkContentElement parentFCE = parent as FrameworkContentElement; if (parentFCE != null) { parentFCE.AddLogicalChild(child); } } } }
public void ResourceInheritanceTest() { object value; FrameworkElement root = new FrameworkElement(); root.Resources = new ResourceDictionary(); root.Resources.Add("key1", "value1"); Assert.IsTrue(root.TryGetResource("key1", out value)); Assert.AreEqual("value1", value); FrameworkElement child1 = new FrameworkElement(); root.AddVisualChild(child1); root.AddLogicalChild(child1); Assert.IsTrue(child1.TryGetResource("key1", out value)); Assert.AreEqual("value1", value); child1.Resources = new ResourceDictionary(); child1.Resources.Add("key1", "value2"); FrameworkElement child2 = new FrameworkElement(); child1.AddVisualChild(child2); Assert.IsTrue(child2.TryGetResource("key1", out value)); Assert.AreEqual("value2", value); root.AddLogicalChild(child2); Assert.IsTrue(child2.TryGetResource("key1", out value)); Assert.AreEqual("value1", value); }