tags:

views:

30

answers:

1

I want to implement functionality that allows a user to move their mouse over a button and a tooltip will appear. The tooltip will display a scaled down preview of a specific ViewModel.

I have implemented most of this, but, if I take the simplest approach of basically using a ContentPresenter to present the ViewModel, then every time the user moves their mouse over the button, such that the tooltip is displayed, the ContentPresenter will be rendered, which really means that the type-referential data template for my ViewModel will be rendered everytime, which will cause too much overhead, which I don't want, since the data template contains some third party controls that take several seconds to render.

So, to my question.... how can this be done in a way that the preview is only rendered initially, and then somehow stored in memory for subsequent viewing?

Chris

A: 

Sounds like you might need to render and cache the controls up front, using the predicted values to populate them. Then store their appearances as ImageBrushes, frozen, in a dictionary keyed by their configuration. It doesn't sound like you're going to get a view only solution for this quite application specific requirement.

How much does the configuration data for the ViewModel vary as the user interacts with the page? How soon can you cache? If you know all the data upfront you can start rendering the snapshots as soon as you load. If you're waiting for input you might not be able to offset the rendering time to where the user won't notice it. But it sounds like that's your aim, to make sure the user doesn't pay the rendering cost at the point of mouseover. Maybe a sample snapshot of the relevant ViewModel holding sample data would do?

Chris Hagan