.NET MAUI › XAML & Markup Extensions
What is the difference between StaticResource and DynamicResource?
AdvancedAnswer
StaticResource resolves the resource once at load time—efficient but won't reflect later changes. DynamicResource keeps a live link, updating the target if the resource is replaced (e.g., swapping a theme dictionary at runtime). Use DynamicResource only where runtime changes are needed, since it has slight overhead.
<!-- Updates live if 'Primary' is swapped at runtime -->
<Button BackgroundColor="{DynamicResource Primary}" />Real-world example Theme colors use DynamicResource so switching light/dark at runtime recolors the UI instantly, while static values use StaticResource.