【发布时间】:2017-12-03 16:02:21
【问题描述】:
我目前被困在 Visual Studio 2017 中的一个项目中。以下代码用于在 .xaml 页面上设置 Image 组件的来源。
private void setImage()
{
var image = new Image();
var imageUrl = @"http://ddragon.leagueoflegends.com/cdn/5.2.1/img/" +
currentChamp.Image.Group + "/" + currentChamp.Image.Full;
Debug.Write(imageUrl);
BitmapImage bmi = new BitmapImage();
bmi.BeginInit();
bmi.UriSource = new Uri(imageUrl, UriKind.Absolute);
bmi.EndInit();
image.Source = bmi;
}
这是要引用的代码。 ^^^
在我发现的所有其他问题中,类似与我所问的问题一致,这一直是我正在尝试做的正确/回答/批准的方式。但是,我收到了一个没有人在任何问题中都没有收到的错误
无法将 system.windows.media.imaging.BitmapImage 隐式转换为 Windows.UI.XAML.media.ImageSource
我的导入、引用和类型都已经过检查并且是正确的。我错过了一个框架吗?是否有可能导致此功能不再起作用的更新?
我正在使用 VS2017 在 Microsoft.NETCore.UniversalWindowsPlatform 中工作
请注意,这不是 this 的重复项,因为我没有引用资源文件夹并且我的路径是绝对路径。
【问题讨论】:
标签: c# image xaml url bitmapimage