Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 调整窗口大小时保持两个图像相对缩放_C#_Wpf - Fatal编程技术网

C# 调整窗口大小时保持两个图像相对缩放

C# 调整窗口大小时保持两个图像相对缩放,c#,wpf,C#,Wpf,假设有两幅图像,一幅大的作为背景,一幅小的作为前景。前景正好位于背景的中间,覆盖了相对的部分(例如50%),因此用户将其视为一幅图像 问题是我需要背景来填充不同大小的窗口。将其Stretch值设置为UniformToFill即可。但是如何使前景仍然覆盖50%的背景呢?最好使用矢量图像,因为在调整容器大小时,它可以缩放“自身” 然后根据窗口大小设置边距,如下所示: <Window x:Class="MainWindow" xmlns="http://schemas.microsoft

假设有两幅图像,一幅大的作为背景,一幅小的作为前景。前景正好位于背景的中间,覆盖了相对的部分(例如50%),因此用户将其视为一幅图像


问题是我需要背景来填充不同大小的
窗口。将其
Stretch
值设置为
UniformToFill
即可。但是如何使前景仍然覆盖50%的背景呢?

最好使用矢量图像,因为在调整容器大小时,它可以缩放“自身”

然后根据窗口大小设置边距,如下所示:

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Height="400" Width="400">
<Grid>
    <Image Margin="100">
        <Image.Source>
            <DrawingImage>
                <DrawingImage.Drawing>
                    <GeometryDrawing Brush="#FF000000" Geometry="M14.800615,5.6499605L14.800615,14.800346C10.630442,17.910477 7.8903284,22.840685 7.8903284,28.44092 7.9003286,37.871319 15.530646,45.511639 24.961039,45.521641 34.391431,45.511639 42.011749,37.871319 42.04175,28.44092 42.03175,22.840685 39.291636,17.910477 35.121462,14.800346L35.121462,5.6599612C43.841825,9.5601254,49.912077,18.280493,49.912077,28.44092L49.922077,28.44092C49.912077,42.231503 38.741611,53.391972 24.961039,53.391972 11.170465,53.391972 0,42.231503 0,28.44092 0,18.270493 6.0902529,9.5501251 14.800615,5.6499605z M19.570043,0L30.237043,0 30.237043,33.917 19.570043,33.917z" />
                </DrawingImage.Drawing>
            </DrawingImage>
        </Image.Source>
    </Image>
</Grid>

要始终使用50%的窗口,可以使用绑定属性

还有,也许我能帮你