簡體   English   中英

C# - Windows Universal app - 圖像源不起作用

[英]C# - Windows Universal app - Image Source doesn't work

我正在嘗試在Windows Universal應用程序中為我的圖像定義源代碼,但它給我提供了以下錯誤:

無效的URI:無法確定URI的格式。

imagePath = "Assets/Category-other-dark.png";
Uri uri = new Uri(imagePath, UriKind.Absolute);
ImageSource imgSource = new BitmapImage(uri);
imgCategory.Source = imgSource;

我搜索了許多論壇並嘗試了很多東西,但沒有任何作用。 謝謝。

將其更改為:

imagePath = "ms-appx:///Assets/Category-other-dark.png";
Uri uri = new Uri(imagePath, UriKind.RelativeOrAbsolute);
ImageSource imgSource = new BitmapImage(uri);
imgCategory.Source = imgSource;

您必須使用本地,漫游或臨時:

var uri = new System.Uri("ms-appdata:///local/Assets/logo.png");

試試這個

    imagePath = "Assets/Category-other-dark.png";
    Uri uri = new Uri(imagePath, UriKind.RelativeOrAbsolute);
    ImageSource imgSource = new BitmapImage(uri);
    imgCategory.Source = imgSource;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM