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

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.

Answer Source

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

    <ImageBrush Stretch="None" Source="src"/>

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

    <ImageBrush Stretch="None" 
                Viewbox="0.25, 0.25, 1, 1"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download