Exemple #1
0
        /// <summary>
        /// Gets the parent element from the visual tree by given type.
        /// </summary>
        public static T ParentOfType <T>(this DependencyObject element) where T : DependencyObject
        {
            if (element == null)
            {
                return(null);
            }

            return(element.GetParents().OfType <T>().FirstOrDefault());
        }
 private static void OnVisibleChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
 {
     var parents = dependencyObject.GetParents();
     foreach (DependencyObject parent in parents)
     {
         var l = parent as ListView;
         if (l != null)
         {
             UpdateListView(l);
             return;
         }
     }
 }
Exemple #3
0
 /// <summary>
 /// This recurse the visual tree for ancestors of a specific type.
 /// </summary>
 internal static IEnumerable <T> GetAncestors <T>(this DependencyObject element) where T : class
 {
     return(element.GetParents().OfType <T>());
 }