Jaime Rodriguez On Windows Phone, Windows Presentation Foundation, Silverlight and Windows 7
Last week, Unni and Pete explained to me how Blend resolves Uris. In this post, I will attempt to explain the details and the possible solution. Details: We already knew that at design-time, Blend loads your window, usercontrols, or what every you are designing, in its main process (and main AppDomain). In the default scenario, this would imply that all Uris will not work (since they resolve relative to Blend’s application) but there is some special handling in Blend to handle Uris in XAML. Blend reads the XAML and alters the Uri references so that they resolve relative to the file:// path of the designed application, instead of relative to Blend’s application. For the most part, Blend does a good job and from XAML your Uris will work fine, but you will notice issues when you are resolving Uris that are not in the parsed XAML:
As you already know, I like absolute Uris and the pack syntax; so I am going to stick with it, but now I have to emphasize that you use the full syntax (including the component part) on the Uri. If you do this, Blend seems to resolve very well on most scenarios, including code and bindings!!
I will say it again, full Uri including component part. For example:
Note: I labeled it possible solution because I am aware that not every one likes the full pack syntax. It can be cumbersome. I also have to explain, that not every one needs this solution, you only need it when the Uris come from code and are needed at design-time (in Blend). Mixing and matching Uris might be a good compromise.
Want to see more? This sample shows all kinds of different paths to resolve an image. As you can see, at design-time, the binding ones and the ones that come from code, do work when using a full path.
PingBack from http://www.clickandsolve.com/?p=8684
In this issue: Jesse Liberty, Gerard Leblanc, and Jamie Rodriguez. Shoutouts: The MIX09 blog reports