The Stretch possible values include Fill, None, Uniform which is the default value and UniformToFill. Fill will stretch the image in width and height to fit the Image element. None will keep the image native size. Uniform will set the largest possible size while keeping the aspect ratio unchanged. UniformToFill will size the width and the height proportionately until the image fills the available height and width.

<UserControl x:Class="SilverlightApplication15.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <Button>
            <Image Source="mypix.png" />
        </Button>
    </Grid>
</UserControl>

The following video clip shows the execution of this code sample and provides more information.

Leave a Reply

Your email address will not be published. Required fields are marked *