我有幾個圖像正在顯示,現在有一些圖像的寬度大於圖像的高度。根據圖像寬度和高度更改方向
說:image.GetWidth() > image.GetHeight();
display the image in landscape mode, else display the image in portrait mode.
我已搜查,找不到任何資源,這將幫助我在這種情況下。
任何幫助,將不勝感激。
請不要說我在WP8上。
EDIT
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
@agarwaen是的,在它被呈現在屏幕上之前,然後根據該更改方向 – user2056563
按此鏈接http://stackoverflow.com/questions/11372559/keep-same-layout-when-orientation-changes – Sajeetharan