Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7712789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:43:05+00:00 2026-06-01T01:43:05+00:00

I am trying to bind an image that is saved in isolated storage and

  • 0

I am trying to bind an image that is saved in isolated storage and display it on the same screen as the camera, but I can’t seem to get the image to display. I don’t know if it because I am not saving it on the phones camera roll, but I am not saving them because I am gonna take multiple pictures and display them like a film strip across the bottom of the view finder for the camera. Can anyone help me please?

I am using this tutorial Here

public partial class Page1 : PhoneApplicationPage
{
private static ObservableCollection<PhotoImage> photoList = new ObservableCollection<PhotoImage>();//For the class and list
private int savedCounter = 0;



public Page1()
{
        InitializeComponent();
}


private void ShutterButton_Click(object sender, RoutedEventArgs e)
    {
        if (cam != null)
        {
            try
            {
                // Start image capture.
                cam.CaptureImage();

            }
            catch (Exception ex)
            {
                this.Dispatcher.BeginInvoke(delegate()
                {
                    txtDebug.Text = ex.Message;
                });
            }
        }
    }

    void cam_CaptureCompleted(object sender, CameraOperationCompletedEventArgs e)
    {
        // Increments the savedCounter variable used for generating JPEG file names.
        savedCounter++;
    }

    void cam_CaptureImageAvailable(object sender, Microsoft.Devices.ContentReadyEventArgs e)
    {
        string fileName = "MyImage" + savedCounter + ".jpg";

        try
        {   

            // Save picture to the library camera roll.
            //library.SavePictureToCameraRoll(fileName, e.ImageStream);//dont want to save it to the camera roll


            // Set the position of the stream back to start
            e.ImageStream.Seek(0, SeekOrigin.Begin);

            // Save picture as JPEG to isolated storage.
            using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream targetStream = isStore.OpenFile(fileName, FileMode.Create, FileAccess.Write))
                {
                    // Initialize the buffer for 4KB disk pages.
                    byte[] readBuffer = new byte[4096];
                    int bytesRead = -1;

                    // Copy the image to isolated storage. 
                    while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0)
                    {
                        targetStream.Write(readBuffer, 0, bytesRead);
                    }

                }

            }

            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {

                photoList.Add(new PhotoImage(fileName));//here is where I set with the file name
                listBoxSearch.ItemsSource = photoList; //here is the binding 
            });


        }
        finally
        {
            // Close image stream
            e.ImageStream.Close();
        }

    }
    public class PhotoImage
    {

        public string PhotoItem { get; set; }

        public PhotoImage(string pItem)
        {
            this.PhotoItem = pItem;

        }
    }

here is my XAML code

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="640" />
        <ColumnDefinition Width="160" />
    </Grid.ColumnDefinitions>

    <Canvas x:Name="viewfinderCanvas" Width="640" HorizontalAlignment="Left" Margin="0,0,0,143">

        <!--Camera viewfinder -->
        <Canvas.Background>
            <VideoBrush x:Name="viewfinderBrush" />
        </Canvas.Background>
        <TextBlock Height="40" Name="txtDebug" Width="626" FontSize="24" FontWeight="ExtraBold" Canvas.Left="14" Canvas.Top="297" />
    </Canvas>

    <!--Button StackPanel to the right of viewfinder>-->
    <StackPanel Grid.Column="1" >
        <Button x:Name="ShutterButton" Content="SH" Click="ShutterButton_Click" FontSize="26" FontWeight="ExtraBold" Height="75" />
    </StackPanel>
    <Grid>
        <ListBox Foreground="RoyalBlue" Height="131"  Name="listBoxSearch"  Width="438"  TabIndex="10" Margin="96,343,106,6">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Height="Auto" >
                        <Image Height="73" Width="73" VerticalAlignment="Top" Margin="0,10,8,0" Source="{Binding PhotoItem }" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

    </Grid>

</Grid>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:43:06+00:00Added an answer on June 1, 2026 at 1:43 am

    Okay – the issue is that does not have an implicit converter that knows how to take an IsoStorage URI and load it.

    One easy solution is to add another property to your PhotoImage class and bind to it instead – here’s a quick and dirty:

    public ImageSource SourceItem
    {
      get
      {
        BitmapImage image = new BitmapImage();
        image.SetSource(isStore.OpenFile(PhotoItem, FileMode.Open));  
        return image;
      }
    }
    

    Note that this is not a great solution – I am just showing you the general idea. Things to think about when implementing your own:

    1. The stream is not being discarded. Wrap the Stream in a using when setting it into image.
    2. Depending on what you are trying to do, you may want to use image.CreateOptions to make the app more responsive (but then you need to figure out how to handle the stream needing to be kept opened)
    3. Finally, the image that will be loaded will be at full resolution. You may want to look into PictureDecoder.DecodeJpeg() to load a thumbnail of the image instead (or look at the thumbnail provided by the camera object)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to load and display a .png image that has transparency in
I'm writing a WPF application and trying to bind an image to my view
I'm trying to bind a list of custom objects to a WPF Image like
i'm trying to bind 2 textures for my shader. But for some reason it
I am trying to make a ScrolledWindow that can scroll over a grid of
I am trying to retrieve the image from resource file and tryin to bind
I am trying to model the layout that is displayed in this image .
I am trying to get backbone.js to load json. The json loads but i
I'm trying to make a jQuery image overlay on div hover function, but I'm
Im trying to bind a list with datetime objects to my repeater. if (e.Item.ItemType

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.