Windows8用のMetroUIアプリで作業しており、プロジェクトフォルダーから画像を取得しようとしています。
これが私の最初のコードです:
public static Image GetImage(string path, int width, int height, int margin)
{
Image img = new Image();
img.Width = width;
img.Height = height;
img.Margin = new Windows.UI.Xaml.Thickness(margin);
BitmapImage bi = new BitmapImage(new Uri(path, UriKind.Absolute));
img.Source = bi;
return img;
}
そして、メソッド呼び出し:
Image = Extension.GetImage("Classe;component/Images/faq.png", 100, 100, 0);
そしてエラー:
Exception:Thrown: "Invalid URI: The format of the URI could not be determined." (System.UriFormatException)
A System.UriFormatException was thrown: "Invalid URI: The format of the URI could not be determined."
URIの種類を相対に変更した場合:
Exception:Thrown: "The given System.Uri cannot be converted into a Windows.Foundation.Uri. Please see http://go.microsoft.com/fwlink/?LinkID=215849 for details." (System.ArgumentException)
A System.ArgumentException was thrown: "The given System.Uri cannot be converted into a Windows.Foundation.Uri. Please see http://go.microsoft.com/fwlink/?LinkID=215849 for details."
画像パスはImages/faq.pngです。コンテンツに設定し、常にコピーします。