Beispiel #1
0
 internal static void ForEachParentAndNode <TNodeType>(DependencyObject node, Func <TNodeType, bool> callback) where TNodeType : class
 {
     foreach (DependencyObject dependencyObject in VisualTreeExtensions.GetVisualAncestorsAndSelf(node))
     {
         TNodeType nodeType = dependencyObject as TNodeType;
         if ((object)nodeType != null && !callback(nodeType))
         {
             break;
         }
     }
 }
Beispiel #2
0
        internal static IUnparentedPopupProvider GetUnparentedPopupProvider(DependencyObject element)
        {
            IUnparentedPopupProvider unparentedPopupProvider = (IUnparentedPopupProvider)null;

            foreach (DependencyObject dependencyObject in VisualTreeExtensions.GetVisualAncestorsAndSelf(element))
            {
                unparentedPopupProvider = dependencyObject as IUnparentedPopupProvider;
                if (unparentedPopupProvider != null)
                {
                    break;
                }
            }
            return(unparentedPopupProvider);
        }
        private static Transform TransformToAncestorHelper(FrameworkElement element, DependencyObject parent, DependencyProperty property)
        {
            Matrix matrix = Matrix.Identity;

            foreach (DependencyObject dependencyObject in VisualTreeExtensions.GetVisualAncestorsAndSelf((DependencyObject)element))
            {
                if (dependencyObject != parent)
                {
                    Transform thisObject = (Transform)dependencyObject.GetValue(property);
                    if (thisObject != null)
                    {
                        matrix = MatrixHelper.Multiply(matrix, TransformExtensions.GetMatrix(thisObject));
                    }
                }
                else
                {
                    break;
                }
            }
            return((Transform)TransformExtensions.MakeMatrixTransform(matrix));
        }