Calls apply whenever element is in a visual tree and
the application theme differs from the one in effect when the content was last built:
on a theme switch while attached, and on attach after a switch that happened while detached.
While the element is hidden (it or an ancestor has Avalonia.Visual.IsVisible off, as
with a viewer on an inactive tab), the rebuild waits until it is shown again.
The caller builds the initial content itself; apply is not called here.
public static void ReapplyOnThemeChange(StyledElement element, Action apply)
The element that hosts the theme-dependent content. It must stay in the document for as long as the content should follow the theme.
Rebuilds the content for the current application theme.
The handler listens to element's own inherited
Avalonia.StyledElement.ActualThemeVariantChanged event, so nothing outside the element
references it: an element that is never shown, or is discarded, is collected normally.