Jamie Marshall Jamie Marshall - 1 year ago 67
C# Question

WPF Static Background Image

How do you get a static background image in WPF. With an image set using the

imagebrush
it always expands or contracts when I resize or extend my window. How do I make the image static so when I extend a window more of the image is revealed and not resized? ie - similar to web design css or something like that.

ASh ASh
Answer Source

set ImageBrush property Stretch to None (default is Fill).

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

Might also need to anchor it to a corner (probably top left) using AlignmentY & AlignmentX.

<Window.Background>
    <ImageBrush Stretch="None" 
                Source="src"
                Viewbox="0.25, 0.25, 1, 1"
                AlignmentY="Top"
                AlignmentX="Left"/>
</Window.Background>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download