Menu
I'm using XamlWriter to serialize a group of WPF objects. One of these objects is an Image control whose Source is set to a file on disk. When the XamlWriter serializes the objects, it sets the source image to an Uri that points to the file on the filesystem. Is there a way to include that data in the Xaml so that instead of referencing the file, the information is stored in xaml?
Thanks -Problems Reply- From MSDN: Serialization Limitations of XamlWriter.Save 'Images are also serialized as object references to images as they exist in the project, rather than as original source references, losing whatever filename or URI was originally referenced.' Well, what I did in the end was build a wrapper class that used a binary serializer to store the images and the xaml code from the XamlWriter. Category: Views: 14 Time:2009-06-24.
Hi Static Shock, I have read through your post for more than two times, but still couldn't understand your problem. Could you please explain your problem in a simple way. If possible, please reproduce the prolem in a simple project and send it to me. My email address is [email protected]. Sincerely, Linda Liu MSDN Subscriber Support in Forum If you have any feedback on our support, please contact Please remember to mark the replies as answers if they help and unmark them if they provide no help.
I can't use FlowDocument, because it doesn't allow placeing elements at fixed positions of the page. I need to use FixedDocument. Framework itself can't serialize FixedDocument with it's used resources (like images).
Welcome to the If you have any feedback, please tell us. Hi Could you be more specific regarding the clipboard interaction and xaml serialization questions? Trying to answer some of the concerns: the URI specified in first xaml snippet is a pack uri, and WPF is able to handle pack URIs (please refer to MSDN for pack URI overview). IE/Word - a program whcih is source of clipboard copy operation is free to determine supported data formats, that's why you're seeing different lists for IE and Word.
PNG file issue - having the stream for png data you could write it to a file using StreamReader and FileStream classes I think. Hope this helps. Thank you for replying. I was able to resolve most of my issues by reposting on the following two threads: I had read up on the pack uri, but the 'payload' form didn't seem to be well documented.
I surmised that this referenced something from within the flowdocument itself, but still don’t really understand the (pack://payload) form. I also understand that applications (such as IE or Word) can put multiple formats of the same data in the clipboard, so that the receiving application has a greater chance of understanding/using the data. Unfortunately, I was unable to find much information on the various formats exposed by the IDataObject GetFormats call.
![]()
The right answer for me is probably just not to use the IDataObject at all, but it seems that it would be useful if there were some guidance about the formats available via this interface. While MS can’t be responsible for ever format of data placed on the clipboard, it could provide information about the commonly seen formats used by their primary applications. Since changing my approach this isn’t a huge deal but it does seem like this would be useful information for the community at large. I was able to get around (ignore) the PNG issue. Still it seems both unusually easy and unusually difficult to use images in WPF. On the one hand I can simple provide a URI to a file (assuming I have one). But if I want to programmatically embed an image in WPF based on a memory stream (like I might get from the clipboard) it seems strangely difficult.
I suspect I’m just not understanding something. It’s really odd, I feel like I can do so much with WPF, right up till I try to actually do it, then the simplest things seem to trip me up.
I’m still working on understanding the use of adorners and how I might programmatically apply an adorner to an image within a flowdocument. Hopefully, I’ll be able to post a specific question a bit later.
Thank you for replying. I was able to resolve most of my issues by reposting on the following two threads: I had read up on the pack uri, but the 'payload' form didn't seem to be well documented. I surmised that this referenced something from within the flowdocument itself, but still don’t really understand the (pack://payload) form. I also understand that applications (such as IE or Word) can put multiple formats of the same data in the clipboard, so that the receiving application has a greater chance of understanding/using the data. Unfortunately, I was unable to find much information on the various formats exposed by the IDataObject GetFormats call. The right answer for me is probably just not to use the IDataObject at all, but it seems that it would be useful if there were some guidance about the formats available via this interface. While MS can’t be responsible for ever format of data placed on the clipboard, it could provide information about the commonly seen formats used by their primary applications.
Since changing my approach this isn’t a huge deal but it does seem like this would be useful information for the community at large. I was able to get around (ignore) the PNG issue.
Still it seems both unusually easy and unusually difficult to use images in WPF. On the one hand I can simple provide a URI to a file (assuming I have one).
But if I want to programmatically embed an image in WPF based on a memory stream (like I might get from the clipboard) it seems strangely difficult. I suspect I’m just not understanding something. It’s really odd, I feel like I can do so much with WPF, right up till I try to actually do it, then the simplest things seem to trip me up. I’m still working on understanding the use of adorners and how I might programmatically apply an adorner to an image within a flowdocument. Hopefully, I’ll be able to post a specific question a bit later. Do you have a complete example of your final solution?
I too need to do this exact thing. Thanks, Linda Rawson Linda Rawson at Sensory Technology.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |