wpf: How to keep an image stay in its original size?

Posted by Martin Luo on Stack Overflow See other posts from Stack Overflow or by Martin Luo
Published on 2010-06-16T17:09:07Z Indexed on 2010/06/16 17:12 UTC
Read the original article Hit count: 189

Filed under:
|

hi, guys! i have a problem about the image display in wpf. here's my code

<Button HorizontalAlignment="Left" Grid.Column="1" Grid.Row="5" Margin="0,5">
        <Button.Content>
            <StackPanel Orientation="Horizontal" Margin="10,0">
                <Image Source="/images/user_add.png" Stretch="None" HorizontalAlignment="Center" VerticalAlignment="Center" Width="24" Height="24" />
                <TextBlock Text="??" />
            </StackPanel>
        </Button.Content>
    </Button>

i hava the image with original size 32*32, but when i ran the above code, the image will stretch to fill all the space, beyond its original size, and i also set the "Stretch" property to "None", but it seems that it doesn't work.

so, how can i fix this problem? thank u~~~!

© Stack Overflow or respective owner

Related posts about wpf

Related posts about image