0
我是WPF的新手,並且在修改文件時遇到了一些問題。動態更改圖像源
我有稱爲IMAGE1圖像控制,這是我以下列方式
string fileName = "C:\\Users\\..\\myImage.jpg"
BitmapImage tmp = new BitmapImage();
tmp.BeginInit();
tmp.UriSource = new Uri(@fileName, UriKind.Absolute);
tmp.CacheOption = BitmapCacheOption.OnLoad;
tmp.EndInit();
Image1.Source = tmp;
這工作的第一次,但然後我運行它會覆蓋myImage.jpg的功能,在該點我把這種加載重新編碼,期待Image1更新。但是,GUI保持不變。它與cacheoption有什麼關係?我需要這樣才能覆蓋文件。
谷歌上的第一個鏈接:http://stackoverflow.com/questions/1491383/reloading-an-image-in-wpf – Yogee