Add an image
<Image Source ="Assets/test_image1.png" Stretch="UniformToFill" /> <Image Source ="Assets/Background.png" Stretch="UniformToFill" HorizontalAlignment="Center" VerticalAlignment="Center" /> <Image Canvas.Left="380" Canvas.Top="198" Width="40" Height="40" Source="Assets/Icon_Loading.png" x:Name="LoadingIcon" />
None – No scaling is done.
Fill – Image will fill the space and aspect ratio is ignored.
Uniform – Show the entire image with blank space in one axis if needed.
UniformToFill – Ensure the whole space is filled and the aspect ration is preserved, cropping if necessary.
Adding image files to the assets folder
You need to right click the Assets folder in Visual Studio and select Add existing item (you can’t just copy files into the folder in explorer)
Image From Local Folder
img.Source = new BitmapImage(new Uri("ms-appdata:///local/SomeFolder/Logo.png"));
Spreading across whole grid
<Image Source="MyImage.png" Stretch="UniformToFill" Grid.ColumnSpan="999" Grid.RowSpan="999"/>
Changing Image Without Blanking
Preloading the image doesn’t seem to work, the workaround until this gets fixed seems to be to have 2 images, one set to collapsed. When you want to display a new image set the collapsed visibility one to show it and create a method for its ImageOpened event which makes it visible and collapses the visibility of the other. Dull, but does the job