.NET MAUI › Styling, Resources & Themes
What is BasedOn style inheritance and when is it useful?
IntermediateAnswer
BasedOn lets a Style inherit setters from another keyed Style, overriding or adding a few. It reduces duplication when you have variants of a base look (e.g., a base button plus primary/secondary variants). The base style must be keyed and in scope.
<Style x:Key="BaseButton" TargetType="Button">
<Setter Property="CornerRadius" Value="8" />
</Style>
<Style x:Key="Primary" TargetType="Button"
BasedOn="{StaticResource BaseButton}">
<Setter Property="BackgroundColor" Value="{StaticResource Primary}" />
</Style>Real-world example Primary and secondary buttons share corner radius and padding from a base style, differing only in color.