Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

listbox problem in windows phone 8

$
0
0

I am developing a windows phone app where I am collecting images from media library and adding each item to listbox.

Here is my code:

privateObservableCollection<img> _pictures =newObservableCollection<img>();publicObservableCollection<img>Pictures{
        get{return _pictures;}}// ConstructorpublicMainPage(){InitializeComponent();
        getImages();}privatevoidPreventCaching(){foreach(var picture in _pictures){
            picture.Imgs.UriSource=null;}}publicvoid getImages(){try{PreventCaching();
            _pictures.Clear();MediaLibrary mediaLibrary =newMediaLibrary();var pictures = mediaLibrary.Pictures;foreach(var picture in pictures){BitmapImage image =newBitmapImage();
                image.SetSource(picture.GetThumbnail());
                img mediaImage =new img();
                mediaImage.Imgs= image;
                _pictures.Add(mediaImage);}
            imageList.ItemsSource= _pictures;}catch(Exception ex){}}publicclass img{public img(){}publicBitmapImageImgs{ get;set;}}privatevoid imageList_SelectionChanged_1(object sender,SelectionChangedEventArgs e){MediaLibrary mediaLibrary =newMediaLibrary();BitmapImage image =newBitmapImage();
        image.SetSource(mediaLibrary.Pictures[imageList.SelectedIndex].GetImage());
        image1.Source= image;}

In Xaml:

<ScrollViewerName="sc"HorizontalScrollBarVisibility="Auto"VerticalScrollBarVisibility="Hidden"Margin="0,422,0,43"><ListBoxName="imageList"SelectionChanged="imageList_SelectionChanged_1"Height="126"><ListBox.ItemsPanel><ItemsPanelTemplate><StackPanelOrientation="Horizontal"></StackPanel></ItemsPanelTemplate></ListBox.ItemsPanel><ListBox.ItemTemplate><DataTemplate><StackPanelOrientation="Horizontal"><ImageMargin="10"Name="image1"Source="{Binding Imgs}"Height="150"Width="150"></Image></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox></ScrollViewer>

Everything is working perfectly for Windows Phone 7.

It is not working for Windows Phone 8,I mean the listbox of images  is not showing in windows phone 8 

I don't have Windows Phone 8 or a emulator for Windows Phone 8. I'm not able to download and install, because I don't have Windows 8 OS.

  1. What's the issue?
  2. Alternatively, is there a way to run Windows Phone 8 emulator in Windows





dj_Fox


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>