Reputation: 3456
I want to resize the image that I am going to display by keeping its aspect ratio.
How can I achieve that. ?
public MainPage()
{
InitializeComponent();
myImage = new Image();
Uri uri = new Uri("Penguins.jpg", UriKind.Relative);
bit = new BitmapImage(uri);
myImage.Source = bit;
imagePanel.Children.Add(myImage);
}
Here the image is stored in the variable bit. How can I resize it by keeping its aspect ratio ?
Thanks.
Upvotes: 2
Views: 875
Reputation: 8126
There is a Stretch
property in Image
class. You can set None
, Uniform
or UniformToFill
to keep aspect ratio when image is resized in order to fill image area
Upvotes: 2