Silverlight/Migration from 1.1

Image.Source는 어떻게 쓰나

길버트리 2008. 3. 6. 20:15
이미지 사용하기가 조금 복잡해졌어요.

Image image = new Image();
image.Source = new BitmapImage(new Uri("http://hugeflow.com/HFLogo.jpg", UriKind.Absolute));

하지만 의미를 찾자면 BitmapImage에 DownloadProgress이벤트가 있다는 것!
이제 이미지가 다 받아졌는지 확인 할 때 Timer 안 써도 된다는 것!

Image image = new Image();
BitmapImage bitmap = new BitmapImage(new Uri("http://hugeflow.com/HFLogo.jpg", UriKind.Absolute));
bitmap.DownloadProgress += new DownloadProgressEventHandler(bitmap_DownloadProgress);

이벤트 핸들러

void bitmap_DownloadProgress(object sender, DownloadProgressEventArgs e)
{
    BitmapImage bitmap = sender as BitmapImage;

    if (e.Progress == 1)
    {
         // 다 받아졌다!
    }
}


네임스페이스

using System.Windows.Media.Imaging;

'Silverlight > Migration from 1.1' 카테고리의 다른 글

Downloader 대신 WebClient  (1) 2008.03.08
HtmlTimer 대신 뭘 쓰면 될까요?  (2) 2008.03.06
BrowserHost야 어딜 간거니???  (4) 2008.03.06