WPF路径调整大小

PaN*_*1Me 3 wpf resize transform path

这是我的路径:

<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>
Run Code Online (Sandbox Code Playgroud)

这会缩放图像,这很好.

问题是路径周围的空白区域(具有原始路径大小的大小)在缩放后保持可见.设置路径的宽度和高度并不能解决问题,因为设置高度例如会导致图像被剪切,但是空白区域仍然存在.

为了清晰起见,我正在添加图片:

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

有帮助吗?谢谢

Edw*_*ard 5

尝试使用LayoutTransform而不是RenderTransform.

ScotLogic博客 - LayoutTransform与RenderTransform

"当应用LayoutTransform时,相邻元素被重新定位以容纳变换后的元素,而使用RenderTransform则不是."