CoverFlowControl in silverlight how can I add pictures ??

I have a CoverFlowControl in xaml page, within this control I am adding pictures with the code

<Image Source="{Binding ImageUrl}" CacheMode="BitmapCache" Height="385" ImageOpened="Image_ImageOpened" />

and it reads an xml file and gets the image url with  

ImageUrl = xMovie.Element("poster").Element("location").Value;

and it brings the pictures but instead of this I want to read the pictures from a folder instead in my local drive and for that I need to add pictures to my CoverFlowControl.Items.Add() but i can not give the picture name to that it gives an error.. Basically my question is how can I add the pictures on my local drive to CoverFlowControl ??
fatihdiAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
CuteBugConnect With a Mentor Commented:
Create a list of BitmapImage.

List<BitmapImage> myImageSource = new List<BitmapImage>():

//add your images to this list.
myImageSource.Add(...);
myImageSource.Add(...);
myImageSource.Add(...);
myImageSource.Add(...);

CoverflowControl.ItemsSource = myImageSource;
0
 
CuteBugCommented:
Check this link

http://msdn.microsoft.com/en-us/library/system.windows.controls.image.aspx


// Create source
BitmapImage myBitmapImage = new BitmapImage();

// BitmapImage.UriSource must be in a BeginInit/EndInit block
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water Lilies.jpg");

// To save significant application memory, set the DecodePixelWidth or  
// DecodePixelHeight of the BitmapImage value of the image source to the desired 
// height or width of the rendered image. If you don't do this, the application will 
// cache the image as though it were rendered as its normal size rather then just 
// the size that is displayed.
// Note: In order to preserve aspect ratio, set DecodePixelWidth
// or DecodePixelHeight but not both.
myBitmapImage.DecodePixelWidth = 200;
myBitmapImage.EndInit();
//set image source
ImageSource = myBitmapImage;

Open in new window

0
 
fatihdiAuthor Commented:
Unfortunately it did not work for me... it is giving error on

<Image Width="200">
  <Image.Source>
    <!-- To save significant application memory, set the DecodePixelWidth or  
     DecodePixelHeight of the BitmapImage value of the image source to the desired
     height and width of the rendered image. If you don't do this, the application will
     cache the image as though it were rendered as its normal size rather then just
     the size that is displayed. -->
    <!-- Note: In order to preserve aspect ratio, only set either DecodePixelWidth
         or DecodePixelHeight but not both. -->
    <BitmapImage DecodePixelWidth="200"  
     UriSource="C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water Lilies.jpg" />
  </Image.Source>

so is there another way to implement this ? I need to give a source to CoverflowControl as

CoverflowControl.ItemsSource = "source";

and source should be a collection of images... and it should display on CoverflowControl


0
All Courses

From novice to tech pro — start learning today.