开发者

What's the correct way to write an Uri to a resource inside a Silverlight Class Library

开发者 https://www.devze.com 2023-01-22 14:48 出处:网络
I have a Silverlight Business Application project. I also added a Silverlight Class Library to be used from my Silverlight app (of course).

I have a Silverlight Business Application project. I also added a Silverlight Class Library to be used from my Silverlight app (of course).

Inside that library (let's call it helper) I have a folder and some small images. In that same library I have a child window with a Image control which I need to change the source info at runtime (code behind).

I found some code online that should work, as a matter of facts it does, when I add an internet uri, say to a flickr image. So my problem is that I'm not writing the Uri right :(

Uri uri = new Uri("MyProj.Silverlight.Helper;images/error.png",UriKind.Relative);
ImageSource img = new System.Windows.Media.Imaging.BitmapImage(uri);
dlg.image.Source = img;

I feel I've already tried every possible way, obviously I haven't :(

Edit: I found a pretty cool post about it, but st开发者_如何学JAVAill no luck. Has it changed since Silverlight 2?


Use the format: "/MyProj.Silverlight.Helper;component/images/error.png"

The / at the beginning and the keyword component are very important!

Ref: http://msdn.microsoft.com/en-us/library/aa970069.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消