Morning folks,
I've been trying to cut out some of my app's processing when I stumbled upon a suggestion on SO to load all images into a resource dictionary via BitmapImages, then referencing them rather than loading an image each time. My problem is that I need to do this all programmatically, so:
<BitmapImage x:Key="MyImageSource" UriSource="../Media/Image.png" />
has become:
BitmapImage bI = new BitmapImage();
Uri imgUri = new Uri(fI.FullName, UriKind.RelativeOrAbsolute);
bI.UriSource = imgUri;
DataTemplateKey dTK = new DataTemplateKey(typeof(BitmapImage));
imageDictionary.Add(dTK, bI);
Which I think should work, but as it loops due to the images loading based on database content, I immediatly get a key already added error on the second loop-through. Is there any way to create a datatemplatekey that I can name myself rather than have it based on the type?
Thanks, Becky