Link to home
Start Free TrialLog in
Avatar of fatihdi
fatihdi

asked on

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 ??
Avatar of CuteBug
CuteBug
Flag of India image

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

Avatar of fatihdi
fatihdi

ASKER

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


ASKER CERTIFIED SOLUTION
Avatar of CuteBug
CuteBug
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial