Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

LayoutTransform and ScaleTransform; CenterX/CenterY not working

$
0
0
I have an image I am scaling with a ViewBox, setting LayoutTransform to a ScaleTransform. My XAML looks like this:

            <ScrollViewer   

                    x:Name="m_SiteImageScroller"   

                    x:FieldModifier="private"   

                    Grid.Column="0"   

                    HorizontalScrollBarVisibility="Auto"   

                    VerticalScrollBarVisibility="Auto">  

 

            <Viewbox x:Name="m_SiteImageViewbox" x:FieldModifier="private">  

                <Viewbox.LayoutTransform> 

                    <ScaleTransform x:Name="m_Scale" x:FieldModifier="private" /> 

                </Viewbox.LayoutTransform> 

                <InkCanvas x:Name="m_DrawingLayer" EditingMode="None">  

                    <Image x:Name="m_Image" x:FieldModifier="private" Source="Raw.jpg">  

                          

                    </Image> 

                </InkCanvas> 

            </Viewbox> 

        </ScrollViewer> 

 

I then have some C# code which reads a Slider and assigns to ScaleTransform.ScaleX/ScaleY:

        private void m_ScaleAdjuster_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)  
        {  
 
            m_Scale.ScaleX = m_ScaleAdjuster.Value;  
            m_Scale.ScaleY = m_ScaleAdjuster.Value;  
   
        }  
 

Problem is, I can assign any values to the ScaleTransform's CenterX and CenterY properties (to scale from the middle rather than (0,0) ) and they have no effect whatsoever. NONE. I tried using the transform as a RenderTransform instead of a LayoutTransform and setting RenderTransformOrigin to (.5,.5). This works. The image scales from the center (but of course then I have the problems of doing the scaling behind the layout system's back). But I can't for the life of me get the LayoutTransform to work with the CenterX / CenterY properties.

Any ideas?

TIA,
John

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>