Image stretched and centered?

If you put it in a Grid it will be centered automatically.

<Grid>
    <Image Source="a.jpg"/>
</Grid>

The complete control with some more Grids:

<UserControl>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Image Source="a.jpg" Stretch="Uniform"/>
        </Grid>
        <Grid Grid.Row="1" Margin="10">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Button Grid.Column="0" Content="Start"/>
            <Button Grid.Column="2" Content="Stop"/>
        </Grid>
    </Grid>
</UserControl>

Canvas doesn't support the HorizontalAlignment of the image. If you want dynamic layout like this, Canvas is a bad choice (it is useful if you want to actually ignore such layout). What is the exact reason you are using a Canvas?
Just use a Grid:

<Grid Background="#FF881607">
    <Image Source="a.jpg" HorizontalAlignment="Center"  VerticalAlignment="Center" Stretch="Uniform"/>
</Grid>

Tags:

Wpf

Xaml

Stretch