代码之家  ›  专栏  ›  技术社区  ›  Sergio Tapia

如何在WPF中将图像设置为图像控件?

  •  1
  • Sergio Tapia  · 技术社区  · 15 年前

    我想这样做:

    imgUser.Source = new Uri(user.Photo);
    

    但我遇到了一个错误,无法将URI转换为ImageSource。有什么帮助吗?

    1 回复  |  直到 15 年前
        1
  •  4
  •   Quartermeister    15 年前

    BitmapImage 是ImageSource,可以从URI创建:

    imgUser.Source = new BitmapImage(new Uri(user.Photo));
    
    推荐文章