I want to preload my image resources when the application is starting. The images should be cached in the application memory. So I can use the preloaded images in my application.
The problem, if I load a specific View with a lot of images inside, the application hangs a few seconds, after that the view will appear. The application is XAML-based, but the source-property of the image-controls is dynamically changed.
I've tested a few things, but nothing seems to work.
var uri = new Uri ( "pack://application:,,,/Vibrafit.Demo;component/Resources/myImage.jpg", UriKind.RelativeOrAbsolute ); //unit.Image1Uri;
var src = new BitmapImage ( uri );
src.CacheOption = BitmapCacheOption.None;
src.CreateOptions = BitmapCreateOptions.None;
src.DownloadFailed += delegate {
Console.WriteLine ( "Failed" );
};
src.DownloadProgress += delegate {
Console.WriteLine ( "Progress" );
};
src.DownloadCompleted += delegate {
Console.WriteLine ( "Completed" );
};
but the image will not load. The only way to load the image is to show it on the screen within a Image-Control and assign the Source-Property to my newly created BitmapImage-Object. But I don't want to show all images at the startup.