[Tip] 외부이미지 로드 방법
-
2012년 5월 31일 목요일 오전 7:17중재자
외부이미지 로드 방법 알려주세요.
모든 응답
-
2012년 5월 31일 목요일 오전 7:25중재자
서버에서 BitmapImage생성된 이미지 다운받는것은 System.Windows.Media.Imaging 를 이용되어져야 합니다. 인터넷으로부터 다운받고자하는 절대경로를 UriSource를 통해서 지정합니다.그 다음 BitmapImage를 가르키도록 이미지 컨트롤 소스를 가르킵니다.
[XAML] 이미지 로드
<Canvas x:Name="LayoutRoot" Background="White">
<Image x:Name="MyImage"></Image>
</Canvas>[C#] - 서버 단 소스로 이미지 파일을 로드하는 방법 (100% 이미지 로드 완료시 ImageOpened 소멸됩니다)
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
BitmapImage bi = new BitmapImage();
bi.UriSource = new Uri("http://www.silverlightdev.net/images/blogImages/Sample.png");
MyImage.Source = bi;
MyImage.ImageOpened += new EventHandler<RoutedEventArgs>(MyImage_ImageOpened);
}
void MyImage_ImageOpened(object sender, RoutedEventArgs e)
{
// Image load complete.
}
}- 답변으로 표시됨 Jina LeeModerator 2012년 6월 1일 금요일 오전 4:32

