xml ファイルから相対イメージ Uri をロードするプロジェクトがあります。次のように画像を読み込んでいます。
if (child.Name == "photo" &&
child.Attributes["href"] != null &&
File.Exists(child.Attributes["href"].Value))
{
Image image = new Image();
image.Source = new BitmapImage(new Uri(child.Attributes["href"].Value, UriKind.RelativeOrAbsolute));
images.Add(image);
}
「子」オブジェクトは、次のような XmlNode です。
<photo name="info" href="Resources\Content\test.png"/>
デバッグ中、画像は実際の画像で満たされているように見えましたが、何らかの方法でそれらを見たいと思っても何も表示されません。奇妙なことは、プロジェクトに画像を含めると機能することですが、変更後にプログラムを再構築する必要があるため、xmlファイルを使用するための私のポイントは失われるためです。 .