Search code examples
c#wpftransform

add transform to element have transform wpf


Can read already transform from an element and add some transform to it? I try this but it’s haven’t what I want.

ScaleTransform st = new ScaleTransform(1.7,  1.7);

TransformGroup gt1 = new TransformGroup();
gt1.Children.Add(rectangle.RenderTransform);
gt1.Children.Add(st);

it's have already TranslateTransform and when i add scale it go to another position

EDIT:

I use this lib from under link

https://www.codeproject.com/Articles/87944/WPF-Map-Control-using-openstreetmap-org-Data

it set translate and I want after change position have scale on zoom on element


Solution

  • Thanks to Nico Schertler

     ScaleTransform st = new ScaleTransform( 1.7, 1.7);
    
     TransformGroup gt1 = new TransformGroup();
     Transform tt1 = rectangle.RenderTransform;
     gt1.Children.Add(st);
     gt1.Children.Add(tt1);
    

    I should change the order of transformation because if translated first then the scale changes its position.