I have a wpf app with this folder structure:
In the HomeController, I want to access the Images folder. I want to store an image in the Images folder from the HomeController. How can I do this? I tried using pack origin but it takes me to bin.
This should do the trick:
pack://application:,,,/Images/image.png
Can be used in xaml or in code. For more detailed explanation you can review this Microsoft page about it.
In code: Uri uri = new Uri("pack://application:,,,/Images/image.png");
In xaml: <element attribute="pack://application:,,,/Images/image.png"/>
Related
When I set uri string value into richimage src property, I can not see the image on application ui.
If I try to paste the value into browser it shows the image
ie: file:/C:/Users/Dijitaluser/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/o.j2ee/drs/IncomingPaperWorkWebApp.war/WEB-INF/classes/com/acme/resource/images/upload_file.png
As a matter of fact, if i put the image file into the same project as you say image/thefile.png, that's ok. But I use distributed resources project and I get the uri by using resourceBundle. So this solution is useless for me.
I' m trying to test application on my integrated weblogic server, and this uri which is returned by resourceBundleHelper, is already validated by browser. Could you plz give me some suggestions about the issue.
I trasnformed my resources project to web project to use web.xml about defining resources servlet. Then moved my all images in META-INF/adf/images and added into my VisualResourceBundle(extends ListResourceBundle) class.
It works
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/86-images-from-jar-427953.pdf
hope it helps
My Windows Store app/Metro/Win RT app downloads image from server on to some local folder. I need to bind Image control to the downloaded image at runtime.
The problem is that image doesn't show up unless I add it as a binary resource to the project.
My downloaded images are stored in ProjectFolder/Data/Media. Now, here is how I bind image source to image control.
<Image x:Name="WriterImage" Stretch="None" Source="{Binding Path=PersonData.Photo.MediaImageSource"></Image>
public ImageSource MediaImageSource
{
// Here _MediaUrl gets a value: ms-appx:///Data/Media/Writer1.jpg
BitmapImage source = new BitmapImage(new Uri(_MediaUrl));
}
This works only if I add Writer1.jpg as a resource to the project. If I remove it from the project, it doesn't show up.
Note that there are different URL schemes that your application can access:
ms-appx:/// is a read-only location, and refers to files that are included (compiled) with your application, such as resources.
ms-appdata:///local/ refers to local read-write storage for your application. If you are downloading files, my guess is that you should use this URL scheme.
For your example above, I would try using the following URL:
ms-appdata:///local/Data/Media/Writer1.jpg
See the following for more info about URL (URI) schemes: http://msdn.microsoft.com/en-us/library/windows/apps/jj655406.aspx
I have some icons in my WPF project to make the application more user friendly. WPF shows all icons on my computer but when I run the app on other computers it will show some of icons but not all of them. How can I fix it?
Update:
<Image Source="Office/Add-Female-User.ico" Stretch="None" />
I'm sure that all images are accessible because some of them are visible.
You are referencing your images (in your image controls) as Content not Resource. I suspect the problem is your images aren't copied to the output dir. View properties on missing image files and set build action to Content and Copy to output dir to Copy if newer.
For resource referencing see http://msdn.microsoft.com/en-us/library/aa970069.aspx.
I'm creating a deployable module where some parts are written in Silverlight, and I'm making the SL application deployable for OOB usage. However, I want to make Silverlight take the name of the website that it's deployed from, such as, when a user installs it from Example.com, I want to have "example.com application" with the site's own icon in the shortcut. Is there any "supported" method of doing this, or will I be going with locating the XAP file and manually changing AppManifest.xaml inside it?
You will need to find out your URL of your application:
string appURL = Application.Current.Host.Source.AbsoluteUri.Substring(0, Application.Current.Host.Source.AbsoluteUri.IndexOf(#"ClientBin/"));
So this will solve the title problem, next is the icon. You could load the image from the page:
Uri uri = new Uri(String.Format("{0}/favicon.png", appURL));
IconImage.Source = new BitmapImage(uri);
It's not perfect, you will have to manipulate appURL to get the domain name only.
I can do this within code to load a bitmapimage located on the Server under ClientBin\Images folder:
var image = new BitmapImage(new Uri(Application.Current.Host.Source, "./Images/Default.JPG"));
However how do I do this within XAML itself? Is it even possible?
<Image x:Name="NewImage" Source="../Images/Default.JPG"/>
Many Thanks,
Did you try this:-
<Image x:Name="NewImage" Source="/Images/Default.JPG"/>
Urls in Xaml treat the folder from which the Xap is downloaded (ClientBin usually) as the root, i.e. the path "/" points actually at ClientBin.
You can't use a relative path in silverlight for an image on the server since the xap file is downloaded to the client, so the application is not actually running on the server.
you will have to use the full "http://mysite.com/myImage.jpg" path