-
I have some images as BitmapFrames produced by PngBitmapDecoder that I would like to display at various places in my UI. I naively thought that I could use a single BitmapFrame instance inside several controls, but when I do that, I get blanks on screen, and it turns out the PixelWidth and PixelHeight of the BitmapFrame become equal to 1, suggesting the object got trashed. Do you confirm I need to create one BitmapFrame instance per use? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
@trebahl How about share the BitmapSource? |
Beta Was this translation helpful? Give feedback.
-
In fact, I've found out that sharing is not even the problem, I can have the same problem with a single control containing the image, so I suppose I'm doing something wrong. My code:
|
Beta Was this translation helpful? Give feedback.
-
Am I supposed to keep the memory stream alive? |
Beta Was this translation helpful? Give feedback.
-
Can you share some demo including the image? I can set two Image controls to the same BitmapFrame without issues. |
Beta Was this translation helpful? Give feedback.
-
The problem disappears if I don't dispose my memory stream. So it seems that the result of decoding the data is not kept in cache despite what the documentation says about BitmapCacheOption.Default. |
Beta Was this translation helpful? Give feedback.
Sounds like you want BitmapCacheOption.OnLoad.