473,666 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to load a Image on ImageBox in Silverlight after browsing

45 New Member
Hi All,
I have a Image box and a button named Browse below ImageBox on my form.
When the User Clicks on the Browse button it should open Dialog and display images.
Below is my code.
Expand|Select|Wrap|Line Numbers
  1.  
  2. private void btnBrowse_Click(objectsender,RoutedEventArgs e)
  3.  {
  4.   OpenFileDialog imageDialog =new OpenFileDialog();
  5.   //Filter default filetype to be allowed for selection 
  6.  
  7.   imageDialog.Filter = "Pictures (*.jpg)|*.jpg";
  8.   imageDialog.FilterIndex = 1;
  9.  
  10.   //Allows multiple files to be selected 
  11.   imageDialog.Multiselect = true;
  12.  
  13.   //Call the ShowDialog method to show the dialog box 
  14.   bool? userClickedOK = imageDialog.ShowDialog();
  15.  
  16.   //Process input if the user clicked OK 
  17.  
  18.   if (userClickedOK == true)
  19.   {
  20.         image1.Source= ;
  21.   }
  22. }
  23.  
My issue is how should i get the Image in image1.Source.
Expand|Select|Wrap|Line Numbers
  1.             if (userClickedOK == true)
  2.             {
  3.  
  4.                 image1.Source= ;
  5.  
  6.             }
  7.  
Please help me in above Code,how should i use ImageDialog object to get the Image in Image1 imagebox.
Aug 23 '11 #1
1 3385
SEhtesham
45 New Member
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.

Expand|Select|Wrap|Line Numbers
  1. OpenFileDialog objFileDialog = new OpenFileDialog();
  2.             bool? IsSelected = objFileDialog.ShowDialog();
  3.  
  4.             if (IsSelected == true)
  5.             {
  6.                 BitmapImage bitImage = new BitmapImage();
  7.                 bitImage.SetSource(objFileDialog.File.OpenRead());
  8.  
  9.                 //Image1 is object of Image
  10.                 Image1.Source = bitImage;
  11.             }
Aug 25 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
9301
by: Manny Chohan | last post by:
HI Guys, I need to load image in table cell from codebehind. i have the following code: TableRow tRow = new TableRow(); Table2.Rows.Add(tRow); TableCell tCell1= new TableCell(); if (property.Value.ToString()=="1") { tCell1.Image="test";
4
8386
by: Scott Meddows | last post by:
I want to load a multipage TIFF image into memory as an Image object but I read that the FromFile method locks the file. Can I load this into a stream, close the physical file then manipulate the image there? Thanks Scott
2
2648
by: Beruang | last post by:
Hi, How to load image from database MS SQL Server into PictureBox if I have Table called Student(StudID, Name, StudImage) StudImage data types is Image. Thanks
6
2731
by: nuhura01 | last post by:
Hi all... My system contains an image which I have saved it at client side. Unfortunately, when users want to view the image, the image doesn't loaded. If i'm not mistaken, it is set at the HTML code of asp.net web form right? I've set the Image URL to be like this: ImageUrl="C:\ExportImage.gif". I don't want to create a new file for placing the image since other clients who don't have the file might not be able to access the image.
11
3708
by: Chamnap | last post by:
Hello, I have several images that need to be loaded dynamically based on user interaction. Each image size is about 6000x1500 pixels. I see several sites they make the image blur, blur, blur, and the image become clear. I want to know how to do this, or maybe you all have other solutions better than this. Can anyone give me some suggestions and the way how to implement? Thanks
1
1348
by: hamzeh83 | last post by:
hi all, i want load image runtime on crystal report (Windos form) Thanxx
2
1167
by: saadkhan | last post by:
How can i load image in <asp:image....> tag? I`v made coded in both the event of pageload to define imageurl and as well as in imageload event....but nothing is working. Plz help me!
2
3515
by: abcomp01 | last post by:
how to load image and display in flash from http post? i would to http post some website and return captcha something and display captcha from response some website from using actionscript flash?
6
4765
by: ghjk | last post by:
I store images using one of my web pages. Next I want to load image from the db and pass the value to ajax page. Other values got correctly. But didn't get image.This is my code. php page. When user click on select link It pass values to ajax page echo "<td><a href='javascript:void(0);' onclick=\"test('$VehicleNo','$Year','$Other','Image'); return false;\">Select</td>"; This is my ajax code. function...
0
8438
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8348
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7376
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1761
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.