【发布时间】:2015-02-04 04:05:38
【问题描述】:
我显示的图像很少,现在有些图像的宽度大于图像的高度。
说:image.GetWidth() > image.GetHeight();
display the image in landscape mode,
else
display the image in portrait mode.
我已经搜索过,但在这种情况下找不到任何可以帮助我的资源。
任何帮助将不胜感激。
请不要说我在 WP8 上。
编辑
Grid grid = new Grid();
grid.VerticalAlignment = VerticalAlignment.Center;
grid.HorizontalAlignment = HorizontalAlignment.Center;
grid.Height = height; //set height
grid.Width = width; //set width
grid.Background = new SolidColorBrush(Colors.White);
Image img = new Image();
img.VerticalAlignment = VerticalAlignment.Center;
img.HorizontalAlignment = HorizontalAlignment.Center;
img.Source = source;
【问题讨论】:
-
您的问题是什么?是否要测试
image.Width > image.Height? -
@agarwaen 是的,在它被渲染到屏幕上之前,然后根据那个改变方向
-
@Sajeetharan 该链接为我们提供了有关方向的信息,但没有提供如何在运行时动态获取图像的宽度和高度
-
@user2056563 试试这个stackoverflow.com/questions/966696/…
标签: c# image silverlight windows-phone-8 windows-phone