This can be done with the following code snippets.
[XAML]
<StackPanel Name="SampleStackPanel" MouseEnter="SampleStackPanel_MouseEnter" MouseLeave="SampleStackPanel_MouseLeave" >
<StackPanel.RenderTransform>
<ScaleTransform x:Name="myScaleTransform" ScaleX="1" ScaleY="1" />
</StackPanel.RenderTransform>
<TextBlock Text="This is test for render transform"/>
</StackPanel>
[C#]
private void SampleStackPanel_MouseEnter(object sender, MouseEventArgs e)
{
myScaleTransform.ScaleX = myScaleTransform.ScaleY = 2;
}
private void SampleStackPanel_MouseLeave(object sender, MouseEventArgs e)
{
myScaleTransform.ScaleX = myScaleTransform.ScaleY = 1;
}
Reference link: https://docs.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/how-to-apply-a-transform-to-an-element-when-an-event-occurs
Permalink