Skip to content

Commit

Permalink
fix 21503 (#21524)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneDelcroix committed Mar 29, 2024
1 parent ce624a9 commit d7dac41
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Controls/src/Core/AppThemeBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public AppThemeProxy(Element parent, AppThemeBinding binding)
_parent = parent;
Binding = binding;
this.SetDynamicResource(AppThemeProperty, AppThemeResource);
((IElementDefinition)parent).AddResourcesChangedListener(OnParentResourcesChanged);
((IElementDefinition)parent)?.AddResourcesChangedListener(OnParentResourcesChanged);
}

public static BindableProperty AppThemeProperty = BindableProperty.Create("AppTheme", typeof(AppTheme), typeof(AppThemeBinding), AppTheme.Unspecified,
Expand All @@ -27,12 +27,12 @@ public void OnAppThemeChanged()
{
Binding.Apply(false);
}

public AppThemeBinding Binding { get; }

public void Unsubscribe()
{
((IElementDefinition)_parent).RemoveResourcesChangedListener(OnParentResourcesChanged);
((IElementDefinition)_parent)?.RemoveResourcesChangedListener(OnParentResourcesChanged);
}
}

Expand Down

0 comments on commit d7dac41

Please sign in to comment.