Solved

WPF C# - what path is  URI point to

Posted on 2013-06-18
5
417 Views
Last Modified: 2013-07-04
new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "Images/icon.png")))

Where should I put the icon.png?

I thought I should put the icon.png into /application/Images/icon.png where the application (Executeable) is running from /application
0
Comment
Question by:tommym121
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:QPR
ID: 39258339
0
 

Author Comment

by:tommym121
ID: 39259448
This is my line

            Brush brsh = new ImageBrush(new BitmapImage(new Uri("Images//WLM-icon.png")));
It cause an exception on Uri()


            new Uri("Images//WLM-icon.png")      This expression causes side effects and will not be evaluated      System.Uri


I put the image file in this directory
C:\Users\user1\Documents\Visual Studio 2010\Projects\TestWPF\TestWPF\bin\Debug\Images

I am not sure what"s go wrong.  Can someone help?
0
 
LVL 13

Accepted Solution

by:
jonnidip earned 500 total points
ID: 39290130
You better create a Solution Folder (for example: "Icons") in your project and put your images there.
You may then reach your folder this way:
new Uri("pack://application:,,,/<yourProjectName>;component/Icons/WLM-icon.png")

Open in new window


I hope this helps.

Regards.
0
 

Author Closing Comment

by:tommym121
ID: 39300372
Thanks
0
 
LVL 13

Expert Comment

by:jonnidip
ID: 39300385
You're welcome!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now