开发者

How to maintain aspect ratio of a rectangle as user resizes the browser

I开发者_运维百科'm using a rectangle with either with a fill from either a video or image brush. As the user resizes the browser the rectangle resizes, which is fine, except that it must keep it's 4:3 aspect ratio. How can I keep the aspect ratio constant?


Have you tried adjusting the fill property on the video/image brush itself? There are various options to it, and im sure one of them will maintain the aspect ratio.


Image and MediaElement both have stretch properties that allow them to maintain their aspect ratio. You may need to change your control to use these instead of the brushes.


You could put your rectangle inside a Viewbox. It maintains the aspect ratio of its single child control, whilst scaling it to fit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜