File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Microsoft.Toolkit.Uwp.UI/Extensions/Tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -566,24 +566,25 @@ public static IEnumerable<FrameworkElement> FindParents(this FrameworkElement el
566
566
/// <returns>The retrieved content control, or <see langword="null"/> if not available.</returns>
567
567
public static UIElement ? TryGetContentControl ( this FrameworkElement element )
568
568
{
569
- Type ? type = element . GetType ( ) ;
569
+ Type type = element . GetType ( ) ;
570
+ TypeInfo typeInfo = type . GetTypeInfo ( ) ;
570
571
571
- while ( type is not null )
572
+ while ( typeInfo is not null )
572
573
{
573
574
// We need to manually explore the custom attributes this way as the target one
574
- // one is not returned by any of the other available GetCustomAttribute<T> APIs.
575
- foreach ( CustomAttributeData attribute in type . CustomAttributes )
575
+ // is not returned by any of the other available GetCustomAttribute<T> APIs.
576
+ foreach ( CustomAttributeData attribute in typeInfo . CustomAttributes )
576
577
{
577
578
if ( attribute . AttributeType == typeof ( ContentPropertyAttribute ) )
578
579
{
579
580
string propertyName = ( string ) attribute . NamedArguments [ 0 ] . TypedValue . Value ;
580
- PropertyInfo propertyInfo = type . GetProperty ( propertyName ) ;
581
+ PropertyInfo ? propertyInfo = type . GetProperty ( propertyName ) ;
581
582
582
- return propertyInfo . GetValue ( element ) as UIElement ;
583
+ return propertyInfo ? . GetValue ( element ) as UIElement ;
583
584
}
584
585
}
585
586
586
- type = type . BaseType ;
587
+ typeInfo = typeInfo . BaseType . GetTypeInfo ( ) ;
587
588
}
588
589
589
590
return null ;
You can’t perform that action at this time.
0 commit comments