I have a textbox where user will enter the url of the image :
suppose the user enters the following string -> C:\Users\malcolm\Desktop\img.png
imgSilverPart is a image control AND imageUrl is a string what i am getting from a textbox.
imgSilverPart.Source = new BitmapImage(new Uri(imageUrl, UriKind.RelativeOrAbsolute));
But the image is not being displayed.
This won’t work. Silverlight runs in a safe Sandbox and you can’t just access a file on the desktop.
So you have to call an OpenFileDialog, get the Stream to the file the user selected and set the Stream as source of the BitmapImage.
Add a Button in XAML and do the following in the Click event handler:
As an alternative it’s possible to use some special folders if your application runs in elevated trust mode as Out-Of-Browser app.