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 t开发者_StackOverflow中文版he 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.
精彩评论