Select to view content in your preferred language

GraphicsLayer.ToBitmap() issue

692
4
12-06-2011 10:53 PM
DenisT
by
Deactivated User
If I create a graphic, add it to the GraphicsLayer and call GraphicsLayer.ToBitmap(), there is no my new graphic in the bitmap.
If I call ToBitmap later (using timer, for example), then the graphic is there.
It looks like the rendering of GraphicsLayers is async.
Is there any event that is rised when a GraphicsLayer is rendered? How to know when I can call ToBitmap?

Thanks in advance.
0 Kudos
4 Replies
DominiqueBroux
Esri Frequent Contributor
Is there any event that is rised when a GraphicsLayer is rendered? How to know when I can call ToBitmap?


I am not sure you need an event.
Did you try to call ToBitMap by using the Dispatcher, i.e.
Dispatcher.BeginInvoke(()=> { your call to ToBitMap });
0 Kudos
DenisT
by
Deactivated User
Dispatcher not worked for me.
I have attached a simple VS-solution, that shows a problem.

There are two main buttons.

"ToBitmap" button creates a new graphic, refreshes a GraphicsLayer and calls GraphicsLayer.ToBitmap().
There will be no new graphic point in the bitmap.

"ToBitmap() delayed" button will add a new graphic, make a delay using DispatcherTimer and then call GraphicsLayer.ToBitmap().
It works. However you never know how long the graphics layer refreshes itself.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Dispatcher not worked for me.


Right. But 2 levels of dispatcher look working:
Dispatcher.BeginInvoke(() => Dispatcher.BeginInvoke(CreateBitmap));

Don't ask me why:confused: but that may be a workaround.
I don't know any other event to do that. You may try CompositionTarget.Rendering but likely not a good solution either.



0 Kudos
DenisT
by
Deactivated User
Thank you.
0 Kudos