13,347
社区成员
发帖
与我相关
我的任务
分享
BitmapImage source = new BitmapImage(new Uri(@"E:\资料\图片\apic5295_s.jpg"));
if (source.Width <= this.image.Width && source.Height <= this.image.Height)
{
this.image.Stretch = Stretch.None;
}
else
{
this.image.Stretch = Stretch.Uniform;
}
this.image.Source = source;
BitmapImage source = new BitmapImage(new Uri(@"图片路径"));
if (source.Width < this.image.Width || source.Height < this.image.Height)
{
this.image.Stretch = Stretch.None;
}
else
{
this.image.Stretch = Stretch.Uniform;
}
this.image.Source = source;
if (photo.ActualHeight > this.Height)
{
photo.Stretch = Stretch.Uniform;
photo.Height = this.Height;
}
else
{
photo.Stretch = Stretch.None;
}
if (photo.ActualWidth > this.Width)
{
photo.Stretch = Stretch.Uniform;
photo.Width = this.Width;
}
else
{
photo.Stretch = Stretch.None;
}
这样虽然可以做到,但是第一次点击时还是大过,下一张图片才会起效果,没有达到预期效果