Reloading an image in wpf

后端 未结 1 1608
清酒与你
清酒与你 2020-12-05 08:41

I\'m trying to reload an image (System.Windows.Controls.Image) I display in WPF. I set the source like this:

ScreenAtco01Image.Source = new BitmapImage(new U         


        
相关标签:
1条回答
  • 2020-12-05 09:28

    Found an answer that works for me:

    BitmapImage _image = new BitmapImage();
    _image.BeginInit();
    _image.CacheOption = BitmapCacheOption.None;
    _image.UriCachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);
    _image.CacheOption = BitmapCacheOption.OnLoad;
    _image.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
    _image.UriSource = new Uri(@"Y:/screenshots/naratco08-0-0-screenshot.png", UriKind.RelativeOrAbsolute);
    _image.EndInit();
    ScreenAtco01Image.Source = _image;
    
    0 讨论(0)
提交回复
热议问题