I've never seen this before. If I set the background of a canvas like this:
<Canvas.Background>
<ImageBrush ImageSource="Combined Victorian.png" Stretch="None" AlignmentX="Left" AlignmentY="Top" />
</Canvas.Background>
It looks like this at runtime:
Great! Just what I want. But later, on a button press, I'm switching between 2 images for the Canvas background. And when I load the exact same image like this:
ImageBrush brush = new ImageBrush();
brush.ImageSource = new BitmapImage(new Uri(@"Images\Combined Victorian.png", UriKind.Relative));
MainCanvas.Background = brush;
It's squished and looks like this:
How might I solve this?
Your first piece of markup sets Stretch="None" on the imagebrush.
Your code does not.
This is the difference.
Imagebrush inherits from tilebrush and you can see the stretch property on that:
You should probably be setting stretch to uniform if you want to retain aspect ration when the user resizes the window. Like when they start it maximised.