Jason94
Jason94

Reputation: 13610

How can I scale a UIElement in C#?

I have defined a canvas in XAML that I add a lot of figures to in C#. I've got some pinch going on but need some help applying the scale to the UIElement.

I've created my ScaleTransform like this:

ScaleTransform scaleTrans = new ScaleTransform();
scaleTrans.ScaleX = scaleFactor;
scaleTrans.ScaleY = scaleFactor;

But how can I apply it to my UIElement (the only children of my canvas)?

Upvotes: 1

Views: 889

Answers (1)

Luke Marlin
Luke Marlin

Reputation: 1398

You need to use the UIElement.RenderTransform property :

yourElement.RenderTransform = scaleTrans;

Upvotes: 2

Related Questions