图像上的ScaleTransform会留下空白



我正在创建一个带有单个图像和覆盖多边形的对话框。问题是图像的比例与多边形的比例不同,所以我想缩小图像以匹配多边形的比例。但是,当我使用RenderTransform/ScaleTransform标记时,图像的大小会缩小,在对话框的右侧和底部留下空白。是的,覆盖现在可以正常工作,但我想让它填充可用空间来填充窗口。

<Window x:Class="vw.CollImage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Collection Image" Height="700" Width="700"
    WindowStartupLocation="CenterOwner" Grid.IsSharedSizeScope="False"
    Icon="Resourcesty.ico">
    <Viewbox MinWidth="70" MinHeight="70">
        <Grid>
            <Image Name="imgColl" HorizontalAlignment="Left" VerticalAlignment="Top" Source="{Binding ImageData}">
                <Image.RenderTransform>
                    <ScaleTransform ScaleX="0.75" ScaleY="0.75"/>
                </Image.RenderTransform>
            </Image>
            <Polyline Stroke="OrangeRed" StrokeThickness="6" Points="{Binding Coordinates}"/>
        </Grid>
    </Viewbox>
</Window>

将其作为LayoutTransform应用。

最新更新