代码之家  ›  专栏  ›  技术社区  ›  Yanshof

如何在运行时更改图像源?

  •  1
  • Yanshof  · 技术社区  · 15 年前

    我每隔5秒从其他组件获取一个新位图(其他组件上没有任何控件),我需要用新位图更新我的WPF图像控件(每隔5秒…).

    我无法在运行时更新这个WPF图像控件。

    我该怎么做?

    谢谢。

    2 回复  |  直到 8 年前
        1
  •  2
  •   Community CDub    8 年前

    Setting WPF image source in code

    ImgOnForm.Source = new BitmapImage(new Uri(@"/yourApp;component/img.png", UriKind.Relative));
    
        2
  •  1
  •   Myosotis    8 年前

    chemin = "/Assets/Images/" + nomFichier + ".gif";
    MonImage.Source = new BitmapImage(new Uri(base.BaseUri, chemin));
    

    推荐文章