Beispiel #1
0
 /// <summary>
 /// This will search for a parent of the specified type.
 /// </summary>
 /// <typeparam name="T">The type of the element to find</typeparam>
 /// <param name="startingObject">The node where the search begins. This element is not checked.</param>
 /// <returns>Returns the found element. Null if nothing is found.</returns>
 public static T FindParent <T>(DependencyObject startingObject) where T : DependencyObject
 {
     return(TreeHelper.FindParent <T>(startingObject, false, null));
 }
Beispiel #2
0
 /// <summary>
 /// Returns true if the specified element is a child of parent somewhere in the visual
 /// tree. This method will work for Visual, FrameworkElement and FrameworkContentElement.
 /// </summary>
 /// <param name="element">The element that is potentially a child of the specified parent.</param>
 /// <param name="parent">The element that is potentially a parent of the specified element.</param>
 public static bool IsDescendantOf(DependencyObject element, DependencyObject parent)
 {
     return(TreeHelper.IsDescendantOf(element, parent, true));
 }
Beispiel #3
0
 /// <summary>
 /// Tries its best to return the specified element's parent. It will
 /// try to find, in this order, the VisualParent, LogicalParent, LogicalTemplatedParent.
 /// It only works for Visual, FrameworkElement or FrameworkContentElement.
 /// </summary>
 /// <param name="element">The element to which to return the parent. It will only
 /// work if element is a Visual, a FrameworkElement or a FrameworkContentElement.</param>
 /// <remarks>If the logical parent is not found (Parent), we check the TemplatedParent
 /// (see FrameworkElement.Parent documentation). But, we never actually witnessed
 /// this situation.</remarks>
 public static DependencyObject GetParent(DependencyObject element)
 {
     return(TreeHelper.GetParent(element, true));
 }
Beispiel #4
0
 /// <summary>
 /// This will search for a child of the specified type. The search is performed
 /// hierarchically, breadth first (as opposed to depth first).
 /// </summary>
 /// <typeparam name="T">The type of the element to find</typeparam>
 /// <param name="parent">The root of the tree to search for. This element itself is not checked.</param>
 /// <returns>Returns the found element. Null if nothing is found.</returns>
 public static T FindChild <T>(DependencyObject parent) where T : DependencyObject
 {
     return(TreeHelper.FindChild <T>(parent, null));
 }