1.11M Members

How to load a Image on ImageBox in c#.Net after clicking browse button

 
0
 

Hi,
My application is in VS2010,Silverlight and coded in C#.Net.
My requirement is i want to upload Image in my Imagebox control.As there is no PictureBox control in Silverlight im using ImageBox.
I have a Imagebox,below that a Browse button.
When the User clicks on Browse button,Dialogbox should open and when the USer selects a Image it should be loaded to Image box..
Example for Picturebox is available on the forum but i want it for Imagebox.
Below is my code.

OpenFileDialog imageDialog = new OpenFileDialog();

            //Filter default filetype to be allowed for selection 
            imageDialog.Filter = "Pictures (*.jpg)|*.jpg";
            imageDialog.FilterIndex = 1;

            //Allows multiple files to be selected 
            imageDialog.Multiselect = true;

            //Call the ShowDialog method to show the dialog box 
            bool? userClickedOK = imageDialog.ShowDialog();

            //Process input if the user clicked OK 

            if (userClickedOK == true)
            {
              image1.Source = 
            }

image1 is my image control
Please correct me in image1.Source=.....

 
0
 

I don't know of any ImageBox in C#.
Only a PictureBox control with an Image property.
To load an image in a picturebox use something like:
pictureBox1.Image = MyJPEGimage;

 
0
 

im Using Silverlight.I have tried Picturebox in normal windows application.
But there is no Picturebox in silverlight application on Imagebox is there.

 
0
 

imageDialog is the object of OpenFileDialog and i was assigning this object to Image Source.

We will have to bind image to Image.Source. Below is the code snippet I tried and able to bind image.

OpenFileDialog objFileDialog = new OpenFileDialog();
            bool? IsSelected = objFileDialog.ShowDialog();
 
            if (IsSelected == true)
            {
                BitmapImage bitImage = new BitmapImage();
                bitImage.SetSource(objFileDialog.File.OpenRead());
 
                //Image1 is object of Image
                Image1.Source = bitImage;
            }
Question Answered as of 2 Years Ago by ddanbe
 
0
 

the following is some codes in loading images form files in C#.

    public static void LoadImageFromFileDemo()
    {
        string fileName = "c:/Sample.png";

        REImage reImage = REFile.OpenImageFile(fileName);

    } 
 
0
 

with proper C# sample codes, you can load image from url and load image from graphics and other routes. thanks for the above helping.

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: