1
xaml 파일에서 이미지를로드 할 수 있습니까? 예 : 모든 이미지 리소스가 포함 된 폴더 IMAGES가 있습니다. 이 이미지는 프로젝트에 추가되지 않았습니다. 가능 Xaml에서 이미지로드
<Image Source="/IMAGES/gift.png" Height="70" Width="70" VerticalAlignment="Top" />
가
또는 내가 코드 뒤에서이를로드해야합니까 : 나는 다음과 같은 코드로 XAML 파일에서 이미지를로드 할?static string path = System.AppDomain.CurrentDomain.BaseDirectory;
static string debug = Path.GetDirectoryName(path);
static string bin = Path.GetDirectoryName(debug);
static string DefaultLayoutFilePath = Path.GetDirectoryName(bin);
public string xmlDefaultLayoutFile = DefaultLayoutFilePath + "\\IMAGES\\gift.png";
및 속성을 변경하는 모든 이미지에 추가 : 프로젝트 폴더에 이미지의 폴더가있는 경우
<Image Source="pack://siteoforigin:,,,/IMAGES/gift.png"
Height="70" Width="70" VerticalAlignment="Top" />
실행되지 않습니다. gift.png이 제 프로젝트에 추가되지 않았기 때문입니다. – huynq9
디버그 폴더 아래에 이미지가 있습니다. 경로는 실행중인 어셈블리에 상대적이어야합니다. 따라서 컴파일 된 exe가 \ bin \ Debug 폴더에 있다면 파일은 \ bin \ Debug \ IMAGES \ gift.png에 있어야합니다. –