File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Microsoft.Toolkit.Uwp.UI/Extensions/FrameworkElement Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,23 @@ public static partial class FrameworkElementExtensions
179
179
goto Start ;
180
180
}
181
181
}
182
+ else if ( element is ContentPresenter contentPresenter )
183
+ {
184
+ // Sometimes ContentPresenters are used in control templates instead of ContentControls
185
+ // Therefore we should still check if it's Content is a FrameworkElement and match.
186
+ // This also makes this work for SwitchPresenter.
187
+ if ( contentPresenter . Content is T result && predicate . Match ( result ) )
188
+ {
189
+ return result ;
190
+ }
191
+
192
+ if ( contentPresenter . Content is FrameworkElement content )
193
+ {
194
+ element = content ;
195
+
196
+ goto Start ;
197
+ }
198
+ }
182
199
else if ( element is UserControl userControl )
183
200
{
184
201
// We put UserControl right before the slower reflection fallback path as
@@ -370,6 +387,17 @@ public static IEnumerable<FrameworkElement> FindChildren(this FrameworkElement e
370
387
goto Start ;
371
388
}
372
389
}
390
+ else if ( element is ContentPresenter contentPresenter )
391
+ {
392
+ if ( contentPresenter . Content is FrameworkElement content )
393
+ {
394
+ yield return content ;
395
+
396
+ element = content ;
397
+
398
+ goto Start ;
399
+ }
400
+ }
373
401
else if ( element is UserControl userControl )
374
402
{
375
403
if ( userControl . Content is FrameworkElement content )
You can’t perform that action at this time.
0 commit comments