DCSIMG
Silverlight 3 Quick Tip #1: How to use WritableBitmap - Alex Golesh's Blog About Silverlight Development

Silverlight 3 Quick Tip #1: How to use WritableBitmap

eWith this post I’m starting the series of Quick Tips post, this time for Silverlight 3.

Today I’ll show how to use WritableBitmap class to paint with content of any Visual element. Let’s start – I created very simple UI with UserControl inside a stack panels and bunch of buttons to control my sample logic

image

By pressing “Paint control” button I’d like to fill the image in  the cell with “Control Image” caption with the picture of the control from the content control in the cell with “Control Instance”. The code is actually very simple:

WriteableBitmap bitmap = new WriteableBitmap(350, 150, PixelFormats.Pbgra32);
bitmap.Render(contentPlaceholder.Content as UIElement, (contentPlaceholder.Content as UIElement).RenderTransform);
 
BitmapSource source = bitmap;
imgControlDrawing.Source = source;

image image

 

Sources as usual – attached here.

 

Stay tuned to more tips and enjoy,

Alex

Published Thursday, March 19, 2009 1:07 AM by Alex Golesh

Comments

# re: Silverlight 3 Quick Tip #1: How to use WritableBitmap

I do agree with all the ideas you have offered in your post. They're very convincing and can definitely work. Nonetheless, the posts are very short for newbies. May just you please lengthen them a little from subsequent time? Thanks for the post.  <a href="michigancarautoinsurance.com/">cheap auto insurance in michigan</a>

Friday, July 29, 2011 7:51 PM by cheap auto insurance in michigan

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: