滑动图像最大高度 [英] Sliding Image Max Height

查看:103
本文介绍了滑动图像最大高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序,它将以幻灯片形式显示许多图像。



图像高度应该是固定的,宽高比保持不变。

如果图像的宽度因此太大,它应该保持从高度调整大小的宽度,并在最左边的点(视图中)开始图像的位置,然后向左滚动到右边唱动画直到它到达另一端。



我不知道如何设置图像控件,所以宽度可以超出其父控件的范围或如何设置所需的动画。



任何人都知道任何地方的开始,想法或链接都很受欢迎。

解决方案

< blockquote>查看此视频,非常好(和简短)解释在控件中调整图像大小。

http://www.youtube.com/watch?v=7LgtNW3HJCU [ ^ ]


您需要设置绑定。此代码将使您的图片适合源元素的高度和宽度。

  var  _img =  new 图片{Stretch = Stretch.Fill,StretchDirection = StretchDirection.Both}; 


var height = new 绑定( ActualHeight){Source = yourSource};
var width = new 绑定( ActualWidth){Source = yourSource};

_img.SetBinding(FrameworkElement.WidthProperty,width);
_img.SetBinding(FrameworkElement.HeightProperty,height);





希望这有助于你


I have a WPF application which is going to display a number of images in a slideshow.

The image height should be fixed and the aspect ratio remain the same.
If the width of the image is therefore too large it should keep the width gained from the height resize and start the position of the image at the furthest left point (in view) and then scroll left to right sing animation till it reaches the other end.

I am not sure how to setup the image control so the width can stretch outside the bounds of its parent control or how to setup the animations required.

Anyone know of anywhere to start, ideas or links are appreciated.

解决方案

Check out this video, very good (and short) explanation of resizing images in controls.
http://www.youtube.com/watch?v=7LgtNW3HJCU[^]


You need to set binding. This code will make your picture to fit height and width of your source element.

var _img = new Image { Stretch = Stretch.Fill, StretchDirection = StretchDirection.Both };

           
var height = new Binding("ActualHeight") {Source = yourSource };
var width = new Binding("ActualWidth") { Source = yourSource};

_img.SetBinding(FrameworkElement.WidthProperty, width);
_img.SetBinding(FrameworkElement.HeightProperty, height);          



Hope this helped you


这篇关于滑动图像最大高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆