WPF 静态背景图片

WPF Static Background Image

如何在 WPF 中获取静态背景图像。对于使用 imagebrush 的图像集,当我调整或扩展我的 window 时,它总是会扩展或收缩。如何使图像静态,以便在扩展 window 时显示更多图像而不调整大小?即 - 类似于网页设计 css 或类似的东西。

将 ImageBrush 属性 Stretch 设置为 None(默认为 Fill)。

<Window.Background>
    <ImageBrush Stretch="None" Source="src"/>
</Window.Background>

可能还需要使用 AlignmentY 和 AlignmentX 将其固定到一个角(可能是左上角)。

<Window.Background>
    <ImageBrush Stretch="None" 
                Source="src"
                Viewbox="0.25, 0.25, 1, 1"
                AlignmentY="Top"
                AlignmentX="Left"/>
</Window.Background>