아래 코드는 다른 프로젝트에서 작동합니다. 또한 두 번째 경우에는 절대 URL을 포함합니다. 내 프로젝트 폴더에 res 폴더가 있습니다. 무엇이 다를 수 있습니까?이미지 상대 경로는 한 프로젝트에서 작동하지만 다른 프로젝트에서는 작동하지 않습니다.
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@"\res\arato.png", UriKind.RelativeOrAbsolute);
myBitmapImage.EndInit();
var img = new Image();
img.Source = myBitmapImage;
img.Margin = new Thickness(0, 0, 0, 0);
canvas.Children.Add(img);
이미지가 '콘텐츠'또는 '리소스'로 설정되어 있는지 여부에 따라 달라질 수 있습니다. – Patrick