Skip to main content
Fixed grammar, spelling, captialization. Added tags.
Source Link
dthrasher
  • 41.5k
  • 34
  • 115
  • 141

wpf WPF: How to keepdisplay an image stay inat its original size?

iI have a problem about the image displaywith displaying images in wpfWPF. here's

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 theI have an image with original size 32*32, but when iI ran the above code, the image will stretch to fill all the space, beyond its original size, and i. I also set the "Stretch" property to "None", but it seems that it doesn't work.

soSo, how can iI fix this problem? thank u~~~Thank you!

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

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~~~!

WPF: How to display an image at its original size?

I have a problem with displaying images 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 have an 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. I also set the "Stretch" property to "None", but it seems that it doesn't work.

So, how can I fix this problem? Thank you!

Source Link
jiluo
  • 2.3k
  • 3
  • 22
  • 34

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

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~~~!