调整窗口大小时会裁切图像

时间:2019-06-25 10:48:39

标签: c# wpf image

我决定将应用程序从WindForms迁移到WPF,并遇到以下问题:我的图像被莫名其妙地裁剪掉。 你能帮助我吗?我在做什么错了?

调整大小之前

https://ibb.co/z4yYdJn

调整大小后

https://ibb.co/6J60Sfc

<Window x:Class="ClientWPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:ClientWPF"
        mc:Ignorable="d"
        Title="Test WPF" Height="535" Width="567" Background="#FF1D1E20">

    <Grid>

        <Image x:Name="back_1" Source="/Resources/background_1.png" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="None"/>
        <Image x:Name="back_2" Source="/Resources/background_2.png" HorizontalAlignment="Left" VerticalAlignment="Bottom" Stretch="None"/>
        <Image Margin="192,75,188,236" Width="160" Height="160" Source="/Resources/logo.png" VerticalAlignment="Center" HorizontalAlignment="Center"/>

    </Grid>
</Window>

1 个答案:

答案 0 :(得分:-1)

我发现了我的错误。由于属性而裁剪的图像:Margin =“ 192,75,188,236”