开发者

How to display images side by side on a windows phone 7?

开发者 https://www.devze.com 2023-01-27 06:56 出处:网络
My wp7 app will get an array of image URLs from the web , number unknown 5-20. I want to put them side by side and user could see them by swipeing right to left,just seeing no choosing or anything.开发

My wp7 app will get an array of image URLs from the web , number unknown 5-20. I want to put them side by side and user could see them by swipeing right to left,just seeing no choosing or anything.开发者_高级运维I manage to convert urls to images but couldnt figure out how to put and show on contentpanel. I tried contentpanel.children.add(image) but it didn't work and showed one image. How should I do this ?


There are lots of ways you could do this.

Here's one way:

<ScrollViewer HorizontalScrollBarVisibility="Auto">
    <StackPanel x:Name="mySP" Orientation="Horizontal" />
</ScrollViewer>

And then just populate the StackPanel with the the images.
Here's it being populated with all the images on the device (or emulator).

var lib = new MediaLibrary();

foreach (var picture in lib.Pictures)
{
    BitmapImage bi = new BitmapImage();
    bi.SetSource(picture.GetImage());

    mySP.Children.Add(new Image { Source = bi });
}


aziz, perfect control for you is WrapPanel from Silverlight Toolkit for Windows Phone 7; check here: http://silverlight.codeplex.com

0

精彩评论

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