0
WPF 4.0을 사용하고 있습니다. WPF의 내 이미지가 표시되지 않는 이유는 무엇입니까?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.IO;
namespace ResourcesLearning
{
class Program
{
[STAThread]
static void Main()
{
Application app = new Application();
Window win = new Window();
Image img = new Image();
String fileName = @"C:\Users\dev\Pictures\1.png";
//It work fine (I see image)
BitmapImage bim = new BitmapImage(new Uri(fileName));
//It not work (I do not see image)
//BitmapImage bim = new BitmapImage();
//bim.UriSource = new Uri(fileName);
//It not work (I do not see image)
//FileStream fs = new FileStream(fileName, FileMode.Open);
//BitmapImage bim = new BitmapImage();
//bim.StreamSource = fs;
img.Source = bim;
win.Content = img;
app.Run(win);
}
}
}
왜 이미지 내 주석 변종이 표시되지 않습니다 : 이것은 내 코드? 첫 번째 변형 만 성공적으로 작동합니다.
디버거를 실행하여 BitmapImage bim = new BitmapImage (새 Uri (fileName)) 다음에 파일 스트림이로드되었는지 확인 했습니까? – Xcalibur37