[SL] Resource로 된 이미지 불러오는 방법

사용자 삽입 이미지

이미지를 불러와서 컨트롤에 삽입하는 방법은 크게 두가지가 있다.

웹상에 있는 파일을 불러와서 로드 하는 방법
XAP파일에 포함시켜서 그 파일을 로드하는 방법

웹상에 있는 이미지 같은 경우는 간단하게 적어주면 된다.

[code xml]
<Image Source="http://reikop.com/buffering_bg.png"/>
[/code]
[code c#]
Uri uri = new Uri("http://reikop.com/buffering_bg.png", UriKind.Absolute);
Image img = new Image();
img.Source = new BitmapImage(uri);
Child.Add(img);
[/code]


그리고 XAP에 포함되어있는 파일은 어셈블리와 함께 적어주면 된다.

[code xml]
<Image Source="/ZetPlayer;component/Asset/buffer_gb.png"/>
[/code]

[code c#]
Uri uri = new Uri("/ZetPlayer;component/Asset/buffer_gb.png", UriKind.Relative);
Image img = new Image();
img.Source = new BitmapImage(uri);
Child.Add(img);
[/code]

다른 어셈블리에 있어도 똑같이 적용해주면 되겠다~
사용자 삽입 이미지

주의할점은 Uri가 상대경로(Relative)인지 절대경로(Absolute)인지 확실히 해야 한다는 점이다.
그리고 이미지 앞에 component/ 라는 경로를 적어주어야 한다.

빌드작업에 Resource가 되어있어야 XAP에 포함된다.

Posted by reiKop

2009/04/01 02:22 2009/04/01 02:22
, , , , , , , ,
Response
No Trackback , No Comment
RSS :
http://reikop.raony.net/blog/rss/response/76


블로그 이미지

HTML, Javascript 이야기

- reiKop

Notices

  1. 첫글.

Archives

Authors

  1. reiKop

Calendar

«   2009/04   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

Site Stats

Total hits:
27037
Today:
6
Yesterday:
59