WPF path resizing

This is my way:

<Style x:Key="MyPath" TargetType="{x:Type Path}">
    <Setter Property="SnapsToDevicePixels" Value="true" />                                    
    <Setter Property="Stroke" Value="Blue" />               
    <Setter Property="Data" Value="M0,100 L 80,40 160,100 M 40,80 L 40,160 120,160 120,80" />
</Style>


<Path Style="{StaticResource MyPath}">
    <Path.RenderTransform>
        <ScaleTransform ScaleX="0.3"
                        ScaleY="0.3" />
    </Path.RenderTransform>
</Path>

It scales the image, which is good.

The problem is that the white space around the path (with the size of the original path size) remains visible after scaling. Setting the width and height of the path does not solve the problem, because setting the height, for example, results in cropping the image, but the space still remains there.

I am adding an image for clarity:

alt text http://img190.imageshack.us/img190/5923/problemis.png

Any help? thank you

+3
source share
1 answer

Try LayoutTransform instead of RenderTransform.

ScotLogic Blog - LayoutTransform vs. RenderTransform

" LayoutTransform, , RenderTransform ."

+5

Source: https://habr.com/ru/post/1732139/


All Articles