Silverlight 4 - Display Images - c#

I am using the following tutorial to implement a gile upload system : file-upload-in-silverlight-a-simple-solution. I can get the images to upload into my Projects.Web folder. However, in my silverlight project I cannot get them to display. This is what I am using to display the image.
<Image Source="..//Theme/Theme2.jpg"/>
However, that fails to display anything although I am sure the path is correct.

If the image is in the ClientBin folder you can use: /images/theme/theme2.jpg
If the image is in the root of the web you can use: http://localhost:57097/images/theme/theme2.jpg

Related

Get Path of local Images in Xamarin Forms

I'm a beginner in terms of Xamarin (Forms) and face the following problem:
I've embedded some images into the project that I can also display in the app using:
<Image Source = 'Example.jpg'/> (XAML or C #)
My intention now is to insert a button that selects a random image from the list for viewing.
My idea was to use a foreach loop to sort the images in an internal List .
However, I would have to know for which path the images are stored.
In a Windows Forms application I would have tried to do that with the help of
DirectoryInfo folderpath = new DirectoryInfo(Environment.CurrentDirectory);
This works in Xamarin Forms but unfortunately not.
Incidentally, I saved these pictures in the solution under Android / Resources / drawable. As I said, I do not get it programmatically (in the C # code) to access it.
For help in this regard, I would be very grateful!
By default A Xamarin.Forms Application searches for image inside the Resources / drawable folder in Android and in Resources for iOS.
For example if you have 10 images to choose from, So what you can do is, name the images as 1.png, 2.png ... 10.png and store in both Android and iOS projects.
On the click on the button generate a random number between 1 to 10 and append ".png" to it and return to the image.
This would be an easier option.
Let me know if you have queries.
After putting your images in suitable Android/Resources/drawable and iOS/Resources folders, In C# code you can give image path like this:
var image = new Image{Source=“example.jpg”}

Setting image path in sql developer to get the image in c# application

I am currently working on a project for school and I have to store image paths in our database in sqldeveloper and then use this path to show the image in our c# application. What I'm currently having problem with is knowing what path to write in the databse so the application can get them from any computers. I have all my images in a document in my project called /Images, but is the path that I have to enter in the DB? Thanks for the help.
You can give your image a unique identifier. So when you save an image in your /Images folder it will have a name like 5a864a4e-23d8-4c08-867a-16e52a4b94be.jpg. Then from your application you could access the image from /Images/5a864a4e-23d8-4c08-867a-16e52a4b94be.jpg. You can give a little more details if you need something more specific. Hope it helps.

Some of the images are not coming after Publishing WPF application

I have published my WPF application using ClickOnce publishing method. I ran the application on the client PC and I noticed that some of my images are not appearing e.g. Background images of Windows. I looked carefully and found out that one Sample.jpg Photo is properly showing inside the Image container which I've used for every record.
Same goes for another image n still coming. The problem I am not able to figure out why both these two images are coming and not the background one?
While creating the Application I have put all the images in a single Folder and all images are referenced from this single folder only.
I also tried by simply copying my project>BIN folder files to client machine and yes, all images are loaded properly without any issues. The problem is only coming in the publish version of my application.
Could anyone help me in this? are there any settings I should take care of while deploying the application? Or I should move them to any specific location?
Are your images Build Action property set to content and the Copy to Output directory property set to Copy always/Copy if newer?

Windows Store Apps: download website content for offline access in webview?

is it possible to download a whole website content, save it in the App's local data folder, then load the website content in a webview so that the user can view it when offline ?
if so, would you please provide me with sample code or reference for APIs to achieve this
download the entire website as a string
use
string testStr = await (new System.Net.Http.HttpClient()).GetStringAsync("http://www.google.com");
but apart from the html content.
1 - The javascript references and the style sheet , the images all need to have a fully referenced path not relative path .
2 - this can be achieved only in Online mode if we have fully qualified path for the above.
3 - to show the images and javascript you need to have it in local storage or known folder or any other accesible folders like the library and all.
4 - U need to append all javascript to the html in order to do webview.NavigateToString(entire string).
5 - So the conceot is a bit too long . Please try following the steps if all resources are available else you wont be able to give it a shot
By resources I mean - Javascript, Images, Css files

silverlight - file extensions

I am working on a file explorer using Silverlight OOB. I need a way to get and display the icon associated with each file in my application. Note, I only need to show the icons, I don´t need to open the files.
If I understood you right, you're building something like Windows Explorer and want to mimic its list view by showing the program icons right before their names.
I'm not sure whether OOB has access to the System.Drawing.Icon class, but if so, you can use the following code to get the icon for any given file:
Bitmap icon = System.Drawing.Icon.ExtractAssociatedIcon(filename).ToBitmap();
If not, the only way you can do it is by storing the icons for most common file formats in a dictionary and retrieving them from there based upon file extension.

Categories