private static void ProcessSources() { if (IsAutoActivationEnabled == false) { return; } var theme = ApplicationThemeCore; foreach (var source in PresentationTreeUtils.EnumerateVisualRoots()) { var freSource = source as FrameworkElement; if (freSource == null) { continue; } var parent = freSource.Parent; var themeTarget = parent is Popup || parent is Window ? parent : freSource; EnsureTheme(themeTarget, theme); } foreach (var enumeratePopup in PresentationTreeUtils.EnumeratePopups()) { EnsureTheme(enumeratePopup, theme); } }
private static void CompositionTargetOnRendering(object sender, EventArgs eventArgs) { foreach (var visualRoot in PresentationTreeUtils.EnumerateVisualRoots().OfType <UIElement>()) { EnsureService(visualRoot); } }
private static DraggableMouseInteraction GetMouseInteraction(MouseEventArgs e) { var uie = PresentationTreeUtils.GetUIElementEventSource(e.OriginalSource); return(uie?.GetVisualAncestorsAndSelf() .OfType <UIElement>() .Select(u => u.GetService <DraggableMouseInteractionService>()) .SkipNull() .SelectMany(s => s._draggableMouseCollection) .Where(d => d.WillHandleEvent(e)) .LastMaxElementOrDefault(d => d.HandlerPriority)); }
private void QueryCloseOnDown(MouseButtonEventArgsInt e) { var uieSource = PresentationTreeUtils.GetUIElementEventSource(e.OriginalSource); var inside = IsInsideClick(uieSource, e); if (inside) { return; } QueryCloseCore(new MouseButtonEventPopupCloseReason(e.OriginalArgs)); }
private static void OnMouseDown(object sender, MouseButtonEventArgs e) { if (e.Handled && e.ClickCount != 1) { return; } var element = (DependencyObject)sender; var uieSource = PresentationTreeUtils.GetUIElementEventSource(e.OriginalSource); if (uieSource.GetVisualAncestors().TakeWhile(p => !ReferenceEquals(p, element)).Any(GetNonSelectable)) { return; } var selectionScope = GetSelectionScope(element); if (selectionScope == null) { return; } selectionScope.SelectedItem = GetSelectTarget(element) ?? element; }
public static IEnumerable <DependencyObject> GetVisualAncestorsAndSelf(this DependencyObject depObj) { return(PresentationTreeUtils.GetVisualAncestors(depObj, true)); }
public static T GetLogicalParent <T>(this DependencyObject depObj) where T : DependencyObject { return(PresentationTreeUtils.GetLogicalParent(depObj) as T); }
public static DependencyObject GetLogicalParent(this DependencyObject depObj) { return(PresentationTreeUtils.GetLogicalParent(depObj)); }
public static IEnumerable <DependencyObject> GetLogicalAncestors(this DependencyObject depObj) { return(PresentationTreeUtils.GetLogicalAncestors(depObj, false)); }
public static IEnumerable <T> GetLogicalAncestors <T>(this DependencyObject depObj) where T : DependencyObject { return(PresentationTreeUtils.GetLogicalAncestors(depObj, false).OfType <T>()); }
private MouseButtonEventInfo GetMouseDownInfo(MouseButtonEventArgsInt e) { var uie = PresentationTreeUtils.GetUIElementEventSource(e.OriginalSource); return(new MouseButtonEventInfo(uie, IsInsideClick(uie, e))); }
public static bool IsKeyboardFocusWithin(DependencyObject dependencyObject) { return(GetKeyboardFocusedElement() is DependencyObject keyboardFocusedElement && PresentationTreeUtils.IsWithinTree(dependencyObject, keyboardFocusedElement)); }
internal static bool IsInLiveTree(this FrameworkElement fre) { return(PresentationTreeUtils.EnumerateVisualRoots().Where(e => e.Dispatcher.CheckAccess()).Any(vr => ReferenceEquals(vr, fre) || vr?.IsVisualAncestorOf(fre) == true)); }
public static DependencyObject GetParent(this DependencyObject depObj, TreeEnumerationStrategy strategy) { return(PresentationTreeUtils.GetParent(depObj, strategy)); }
public static IEnumerable <DependencyObject> GetVisualDescendantsAndSelf(this DependencyObject parent, Func <DependencyObject, bool> excludeSubtree) { return(PresentationTreeUtils.GetVisualDescendants(parent, true, excludeSubtree)); }
public static IEnumerable <T> GetVisualDescendantsAndSelf <T>(this DependencyObject parent) where T : DependencyObject { return(PresentationTreeUtils.GetVisualDescendants(parent, true, null).OfType <T>()); }
public static IEnumerable <DependencyObject> GetVisualDescendantsAndSelf(this DependencyObject parent) { return(PresentationTreeUtils.GetVisualDescendants(parent, true, null)); }
public static IEnumerable <T> GetVisualChildrenAndSelf <T>(this DependencyObject parent) where T : DependencyObject { return(PresentationTreeUtils.GetVisualChildren(parent, true).OfType <T>()); }
public static IEnumerable <T> GetVisualAncestorsAndSelf <T>(this DependencyObject depObj) where T : DependencyObject { return(PresentationTreeUtils.GetVisualAncestors(depObj, true).OfType <T>()); }
public static IEnumerable <DependencyObject> GetVisualChildren(this DependencyObject parent) { return(PresentationTreeUtils.GetVisualChildren(parent, false)); }
public static IEnumerable <DependencyObject> GetAncestorsAndSelf(this DependencyObject depObj, TreeEnumerationStrategy strategy) { return(PresentationTreeUtils.GetAncestors(depObj, true, strategy)); }
public static T GetParent <T>(this DependencyObject depObj, TreeEnumerationStrategy strategy) where T : DependencyObject { return(PresentationTreeUtils.GetParent(depObj, strategy) as T); }
public static IEnumerable <T> GetAncestorsAndSelf <T>(this DependencyObject depObj, TreeEnumerationStrategy strategy) where T : DependencyObject { return(PresentationTreeUtils.GetAncestors(depObj, true, strategy).OfType <T>()); }