With the following code, I can't get the background image to display at its original size (it's always a fair bit larger). I tried changing the Stretch
property, but "None" seems to be the most appropriate value.
<Canvas Width="500" Height="500">
<Canvas.Background>
<ImageBrush
ImageSource="{Binding ElementName=w_window, Path=BackgroundImagePath}"
Stretch="None"
AlignmentX="Left"
AlignmentY="Top"
/>
</Canvas.Background>
</Canvas>
In the image below, you can see my app on the left and photo viewer (set to original size) on the right.
Any advice? (BTW, setting ClipToBounds="True"
doesn't work.)
It seems that my problem isn't restricted to when the image is a background. The following code, in which an Image
is the only element, has the same sizing problem. It's not just my machine having this problem (i.e. the app has this problem on other machines).
<Window x:Class="DiagramDesigner.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2" Height="300" Width="1000">
<Image
Source="C:\Users\patk\Downloads\Bottom_wnums.jpg"
Stretch="None"
HorizontalAlignment="Left"
VerticalAlignment="Top"
/>
</Window>