0

シルバーライトで画像を表示する際に奇妙なバグがあります。xmlファイルに設定された画像の一覧と、サーバーからダウンロードしたこのxmlをWebClientの種類別に表示する問題。

WebClient client = new WebClient();
            client.AllowReadStreamBuffering = true;
            client.OpenReadAsync(new Uri(path, UriKind.Relative), new GalleryUserState() {Gallery=gallery, PathToXml = path });
            client.OpenReadCompleted += new OpenReadCompletedEventHandler(request_for_Gallery_Completed);

xml をダウンロードし、xml から画像を取得した後、奇妙なバグがあります:

スタックパネルに画像を動的に追加します。しかし、画像は常に表示されるわけではありません!画像の読み込みに失敗する場合があります:

    curImage.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(curImage_ImageFailed);
 void curImage_ImageFailed(object sender, ExceptionRoutedEventArgs e)
   {
   }

例外:

ErrorException = {System.Exception: AG_E_NETWORK_ERROR}

ブラウザを更新すると、他の画像の読み込みに失敗します (画像リストは同じです!)。アセンブリ(xap)で構成するイメージを含む同じリストは、常に正常に機能します。

WebClient などの問題のようです。それは何ですか?

4

2 に答える 2

2

UriKind を設定してみてください。

UriKind.RelativeOrAbsolute
于 2010-09-16T18:12:48.433 に答える
2

次のようにロードします。
/[YOUR_PROJECT_ASSEMPLY_NAME];component/[Path_to_images]/[your_image]

サンプル:
/System.Windows.Controls.Data.RIADataFilter.Control;component/Images/Plus.png

于 2010-09-18T08:41:30.020 に答える