From 16f70bf037653af37631d65acf124b901c9f929e Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Thu, 15 Jul 2021 11:32:51 -0700 Subject: [PATCH] Add Viewbox to VisualTreeExtensions FindChild branches --- .../FrameworkElementExtensions.LogicalTree.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/FrameworkElement/FrameworkElementExtensions.LogicalTree.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/FrameworkElement/FrameworkElementExtensions.LogicalTree.cs index 07c27b51012..5b2b370a013 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/FrameworkElement/FrameworkElementExtensions.LogicalTree.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/FrameworkElement/FrameworkElementExtensions.LogicalTree.cs @@ -196,6 +196,20 @@ public static partial class FrameworkElementExtensions goto Start; } } + else if (element is Viewbox viewbox) + { + if (viewbox.Child is FrameworkElement child) + { + if (child is T result && predicate.Match(result)) + { + return result; + } + + element = child; + + goto Start; + } + } else if (element is UserControl userControl) { // We put UserControl right before the slower reflection fallback path as @@ -398,6 +412,17 @@ public static IEnumerable FindChildren(this FrameworkElement e goto Start; } } + else if (element is Viewbox viewbox) + { + if (viewbox.Child is FrameworkElement child) + { + yield return child; + + element = child; + + goto Start; + } + } else if (element is UserControl userControl) { if (userControl.Content is FrameworkElement content)