2

我每 5 秒从某个其他组件(对其他组件没有任何控制)获得新的位图,我需要用新的位图(每 5 秒...)更新我的 wpf 图像控件。

我找不到在运行时更新此 wpf 图像控件的任何方法。

我该怎么做 ?

谢谢。

4

2 回答 2

2

还有一个像这样 在代码中设置WPF图像源的问题

答案归结为

ImgOnForm.Source = new BitmapImage(new Uri(@"/yourApp;component/img.png", UriKind.Relative));
于 2010-10-06T16:35:55.627 回答
1

这对我有用:

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

我在论坛上找到的所有建议都不起作用(我没有图像,或者 ArgumentException)。但是以“base.BaseUri”作为第一个参数,它终于起作用了。

于 2016-11-24T13:50:58.600 回答