Live Chat Icon For mobile
Live Chat Icon

How do I apply Transform when an event is occurred ?

Platform: WPF| Category: Visual Layer

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

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.