WPF doesn't load images correctly - wpf

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.

Related

Custom Font in Silverlight OOB

Can anyone give me a hand on how to use Custom fonts in a Silverlight app in OOB? It works in the browser correctly.
Furthermore, the font is working and referenced correctly as the designer renders what I am after, but when running the app it is ignored.
Thanks heaps
Edit :
Trying to emulate a Mutlimeter display (thus OOB)
FontFamily="/BNA;component/Fonts/Fonts.zip#Crystal"
Font Properties Build Action = "Resource", Copy to Output Directory = "Copy Always"
Got it sorted, had to embed in to the client app side using
FontFamily="/BNA;component/Crysta.ttf#Crystal" and setting the Font as a Resource

How to use relative path of Silverlight app in image control inside user control?

I created a custom user control which contains an <Image /> control. My user control is bound to a CLR object which contains the proper filename to use for the <Image> Source property.
The user control is located under Controls folder in my Silverlight app. When the app runs, the image is only displayed if the image is in the same folder as the user control (i.e. the image must in the Controls folder).
How can I make the image source be relative to the location the Silverlight app is running?
The app is hosted in an ASP.NET MVC application.
A relative path that starts with "/" is considered be routed at the top level of the XAP file and (if the resource is not found in the Xap) in the server folder from which the XAP was downloaded.
In other words place a "/" at the beginning or your Urls and you will probably get the behaviour you describe.

How change the desktop shortcut image of WPF application?

I am creating a WPF Application, and I wanted to publish it. So I created a new Setup and Deployment project, and added my application to it. Now, when I created the setup file and ran it...it created a desktop shortcut. But the image on the desktop shortcut was a windows default, and I want to change it to another icon file. Please tell me how to do that.
Thanks.
First, you will need to add an icon to your project. In the properties of your icon, set Build Action to Resource.
Then, in your main Window.xaml file, set the Icon property.
<Window x:Class="..."
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
**Icon="YourIcon.ico"**>
And also you can add an .ico file to user's program files folder. After that you can add the shourtcut to user's desktop. Important point is you should configure the shourtcut's target to that .ico folder.
I hope this helps
Open Properties window of application. In Application section there is "Icon and manifest". Add icon there. More details is here

Problem publishing images in Silverlight PivotViewer

I'm working on a Silverlight PivotViewer app and using the Excel Pivot Collection tool to generate my image files. Everything works perfectly except some images are not being published by the tool. As a result, when the app launches, everything looks great except there are blank spaces where the unpublished images are supposed to be. All of their data/facets are available if I click on a "blank" image.
When I dig a little deeper and look at the files that are generated, the missing images are not there. What's more interesting, if I look a the cxml file. The images information is all there only the missing images are missing their "img" attribute. For some reason, the Pivot Collection tool recognizes that there are images but chooses not to publish them. I've tried re-creating the images as both PNGs and JPGs to no success.
Does anyone know why this is happening and how I can fix it?
Delete the entire collection_files folder and the cxml file. Republish the images and then add the newly published collection_files folder and cxml file to your project.

Image source using project resource (WPF)

I added a bunch of images as project resources.
Now i want to use them in my WPF application using the image control.
How can I assign the resource to the source of the image control?
First, mark you image file as a "Resource" in the properties window of Visual Studio. Then you can quite easily reference the resource using the file name:
<Image x:Name="image1" Source="theimage.png" />
If you have put your image in a folder, you can use
<Image x:Name="image1" Source="/folder/theimage.png" />
You wanted to reference your image in XAML right?
like this
<Image Source="Resources\MyImage.png" />
and you dont need to add the image to the project resource. just add the images to your project via solution explorer

Resources