Advertisement
Beginner .NET MAUI, Styling, Resources & Themes

What is the difference between an implicit and an explicit Style?

Short answer

An explicit Style has an x:Key and is applied where referenced via Style="{StaticResource ...}". An implicit Style has no key, only a TargetType, and applies automatically to all controls of that type in scope. Implicit styles set defaults; explicit styles are opt-in variants.

Save .NET MAUI mock interview
Advertisement
AModel answer
An explicit Style has an x:Key and is applied where referenced via Style="{StaticResource ...}". An implicit Style has no key, only a TargetType, and applies automatically to all controls of that type in scope. Implicit styles set defaults; explicit styles are opt-in variants.
<Style TargetType="Button">              <!-- implicit: all buttons -->
    <Setter Property="CornerRadius" Value="8" />
</Style>
<Style x:Key="Danger" TargetType="Button"> <!-- explicit -->
    <Setter Property="BackgroundColor" Value="Red" />
</Style>
Real-world example
All buttons get rounded corners via an implicit style, while delete buttons opt into a red 'Danger' explicit style.
Likely follow-ups
  • How do styles inherit? | What is BasedOn?
Related topics