RecentDocumentMenu and images

Ribbon for WPF Forum

Posted 12 years ago by Kasper
Version: 11.2.0552
Avatar

Hi guys,

I want my RecentDocumentMenu to show dynamic images, retrieved from Windows based on the filename. However, apparently this is not supported in the serialization process, so the image is written as an empty XML node, causing an exception to be thrown when I try to load the XML. I can definitely understand if you don't want to serialize anything but an URL, but on the other hand I think we need support for using images that are not physically present. I would probably prefer some sort of event that allowed me to look up the proper image when needed, but perhaps you have an even better idea. Please let me know :)

Comments (6)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Kasper,

For things like this, please always make a new simple sample project and email it to us so we can debug it.  We use the sample both to ensure we are seeing the exact same scenario you are seeing, and also to verify that any related code changes we make will fix your issue.  We plan on getting a maintenance release out soon so it would be helpful if you could get this in shortly.  Thanks!


Actipro Software Support

Posted 12 years ago by Kasper
Avatar

Perhaps I wasn't clear enough (??), but I wasn't really reporting this as a bug. I fully understand that you are not serializing images that I generate dynamically. I was merely asking for your suggestion on how to accomplish the usage of dynamic images, as well as making my own suggestion on how I might prefer it worked.

But perhaps you DO support dynamically generated images and what I'm seeing IS a problem? Otherwise I really don't understand what I'm supposed to create a sample application of and might even fear that I'm no longer talking to an Actipro employee but a robot which automatically asks for sample apps. Hopefully that's not the case ;)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Kasper, the whole reason for samples is to better understand what you are trying to achieve.  Here I assume you are referring to the IDocumentReference.ImageSourceLarge, etc. properties that get serialized by the RecentDocumentManager? 

If so, those properties are the data items that are bound to the RecentDocumentMenu, and the template for RecentDocumentMenu binds them directly to Image controls in the template.  There's nothing really on-demand available since it's all wired up in XAML MVVM-style.

The only thing I can think of is for you to make your own ImageSource class (not sure offhand how easy/hard that is) and inject that into your doc reference instead of a URL based one.  Then make sure it's XAML serializable since our serializer is using XamlWriter/XamlReader to serialize the data out.


Actipro Software Support

Posted 12 years ago by Kasper
Avatar

>Here I assume you are referring to the IDocumentReference.ImageSourceLarge, etc. properties that get serialized by the RecentDocumentManager?

Yes exactly. Sorry if that wasn't clear enough.

>If so, those properties are the data items that are bound to the RecentDocumentMenu, and the template for RecentDocumentMenu binds them directly to Image controls in the template. There's nothing really on-demand available since it's all wired up in XAML MVVM-style.

I understand that. I was thinking about an event on the document manager, whenever an image was not present, but as I mentioned, it was merely a suggestion :)

>The only thing I can think of is for you to make your own ImageSource class (not sure offhand how easy/hard that is) and inject that into your doc reference instead of a URL based one. Then make sure it's XAML serializable since our serializer is using XamlWriter/XamlReader to serialize the data out.

Is it not natural to show the Windows-decided icon next to a filename? I would think that was what the feature was for, which is why I find it a bit unnatural if it's THAT hard to do. That is why I asked for some sort of lazy-load event. Creating an entirely new ImageSource just for this simple purpose seems like way too much work to do something that I would expect to be supported out-of-the-box. However, if you're not interested in supporting this, I will see if I can make a hack to support it myself instead. I just imagined that other customers would want to accomplish the same thing, hence my question/suggestion :)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Could you just update the image sources to the appropriate dynamic image right after you deserialize the list?  If the future serialization is causing you issues when you deserialize the XML, then you'd probably want to clear the image sources (set them to null) right before serializing.

If you are displaying the recent document list in an application menu or a backstage, could you possibly load up the images in a Ribbon.IsApplicationMenuOpenChanged event handler?  You'd still need to null them out when you serialize it all though.


Actipro Software Support

Posted 12 years ago by Kasper
Avatar

>Could you just update the image sources to the appropriate dynamic image right after you deserialize the list? If the future serialization is causing you issues when you deserialize the XML, then you'd probably want to clear the image sources (set them to null) right before serializing.

That's pretty much what I ended up doing a couple of days ago. It's just a bit of a hack, for something I didn't feel should require a hack, but that's really your decision. As long as it works, I'm satisfied :)

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.