Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to have the ReturnButton to be BasedOn the SetupButton style. How do I inherit styles? I want to base the Selector="Button.ReturnButton" on the Selector="Button.SetupButton"
<Style Selector="Button.SetupButton">
	<Setter Property="HorizontalAlignment" Value="Center"/>
	<Setter Property="VerticalContentAlignment" Value="Center"/>
	<Setter Property="BorderBrush" Value="Transparent"/>
	<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
	<Setter Property="VerticalContentAlignment" Value="Stretch"/>
	<Setter Property="Template">
	<Setter.Value>
	   <ControlTemplate TargetType="Button">
	      <ContentPresenter x:Name="contentPresenter"
		  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
		  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
		  Content="{TemplateBinding Content}"
		  RecognizesAccessKey="True"
		  RenderTransformOrigin="0.5,0.5"/>
	      </ControlTemplate>
	</Setter.Value>
	</Setter>
</Style>

<Style Selector="Button.ReturnButton">
	<Setter Property="HorizontalAlignment" Value="Center"/>
	<Setter Property="VerticalContentAlignment" Value="Center"/>
	<Setter Property="BorderBrush" Value="Transparent"/>
	<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
	<Setter Property="VerticalContentAlignment" Value="Stretch"/>
	<Setter Property="Template">
	   <Setter.Value>
		<ControlTemplate>
		   <Grid>
		      <Image Source="/Assets/SetUp/icon_nav_return_alice.bmp" 
				Classes="SetupButtonImage"/>
		   </Grid>
		</ControlTemplate>
	   </Setter.Value>
	</Setter>
</Style>

There was the BasedOn in WPF, but that seems to have disappeared, and not been replaced

What I have tried:

Have tried to use Selector="Button.SetupButton.ReturnButton".
Posted
Comments
Maciej Los 12-Mar-22 5:49am    
I found similar question On GitHub: Style.BasedOn supported? · Issue #2343 · AvaloniaUI/Avalonia · GitHub[^]
It was asked 3 years ago and there's no answers till now :(
But(!) another question on GitHub might be interesting: WPF-style styles · Issue #2765 · AvaloniaUI/Avalonia · GitHub[^]
Clifford Nelson 14-Mar-22 12:31pm    
Thanks. Seems like a strange thing to be missing. I would have thought something like
Selector="Button.SetupButton.ReturnButton" would work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900