I am developing picture viewer application and I want to add new function to it.
Till this time, I have fixed size of Image control in the XAML
Height="422" Width="444",but I want to use all possible space on the page and it is Width="447" Height="585"
<StackPanel Height="422" Width="444">
<Image Height="414" HorizontalAlignment="Center" Margin="9,6,0,0" Name="image2" Stretch="Uniform" VerticalAlignment="Center" Width="441" />
</StackPanel>
Code behind
var stream = new IsolatedStorageFileStream(path, FileMode.Open, _file);
var image = new BitmapImage();
image.SetSource(stream);
stream.Close();
if (image1 != null) image1.Source = image;
So, my question is:
- How I can set the size of the Image control from the code behind, so the picture will fit to the
Width="447" Height="585"size, I have both portrait and landscape oriented pictures? - I need to have portrait and landscape orientation support, so when orientation is change I would like to picture fit to new size
Width="585" Height="447", how I can manage that? (I guess if I will find solution to the first, than only think I need is right event to handle this) Similar to this (http://stackoverflow.com/questions/6857142/handling-size-of-image-after-orientation-change-wp7), but I need to see some code t in order to understand.
Please, post some code or link to the tutorial, in order to prevent “classic” dialog where one person now how to do it and think it is simple and other person have now idea how it work.
You can directly change the size of image control through it’s Width and Height properties.
If you want to fit in your picture in the Image Control properly then you can use property Stretch
For handling the orientation change handle the
OrientationChangedevent of your page and do the image manipulation inside it