I have the following Style for a Button which is supposed to grow to 1.5 times the size when the mouse hovers it. The problem is that Button grows from the Top-Left corner instead of the center. Does anyone know how to fix this?
<Style x:Key="sizeButton" TargetType="Button">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1.5" ScaleY="1.5"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
Tried the solution offered by Henk Holterman but I couldn't get the following code to work. It seems to have no effect or am I doing it wrong?
<Window.Resources>
<Style x:Key="sizeButton" TargetType="Button">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.5" ScaleY="1.5"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<StackPanel>
<Button Content="Increase Size" Width="100" Height="50" Style="{StaticResource sizeButton}"/>
</StackPanel>
question from:
https://stackoverflow.com/questions/5060854/make-scaletransform-start-from-center-instead-of-top-left-corner 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…