How can I prevent the button from getting smaller when pressed? #16100
-
I've tried using the What I tried: <Window.Styles>
<Style Selector="Button.mainButton /template/ ContentPresenter">
<Setter Property="Background" Value="#4798d8"/>
<Setter Property="BorderBrush" Value="Transparent"></Setter>
<Style Selector="^:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="#4798d8"/>
<Setter Property="BorderBrush" Value="#4798d8"></Setter>
</Style>
</Style>
<Style Selector="Button.mainButton:pressed /template/ ContentPresenter">
<Setter Property="Width" Value="600"/>
<Setter Property="Height" Value="250"/>
<Setter Property="Background" Value="red"></Setter>
</Style>
</Window.Styles>
<Grid>
<Button Name="MainButton"
Width="500" Height="150"
Cursor="Hand"
Focusable="False"
Classes="mainButton"> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
First, you always need to read the original Avalonia/src/Avalonia.Themes.Fluent/Controls/Button.xaml Lines 51 to 53 in 2a9e7e9 In this instance, you can easily replace this with a new selector: <Style Selector="Button:pressed">
<Setter Property="RenderTransform" Value="{x:Null}" />
</Style> You could also set |
Beta Was this translation helpful? Give feedback.
First, you always need to read the original
ControlTheme
. For Fluent, the relevant bit is here:Avalonia/src/Avalonia.Themes.Fluent/Controls/Button.xaml
Lines 51 to 53 in 2a9e7e9
In this instance, you can easily replace this with a new selector:
You could also set
Value="scale(1)"
, but no transform should be more efficient.