views:

318

answers:

2

i want to do a screen capture of a running silverlight 3 application, from within the app, and then i want to present this to the user as a thumbnail, say in an Image control.

am i dreaming?

+2  A: 

For a simple page:

<Grid x:Name="LayoutRoot" Background="White">
    <StackPanel>
        <Ellipse Fill="Red" Width="100" Height="100"></Ellipse>
        <Button x:Name="btnCapture" Click="btnCapture_Click" Width="30" Height="25"></Button>
        <Image x:Name="imgThumbnail" Width="50" Height="50"></Image>
    </StackPanel>
</Grid>

with the event handler:

    private void btnCapture_Click(object sender, RoutedEventArgs e)
    {
        WriteableBitmap bmp = new WriteableBitmap(LayoutRoot, null);
        this.imgThumbnail.Source = bmp;
    }
Ryan Bates
this works out quite well for the use case; thanks very much for this Ryan.
velvet sheen
small followup, let's say I'd like to record what's going on the screen in a movie like manner and then play it back to the user... how should this be done ?
vondip
A: 

You are dreaming if you want to do a true screen capture (outside the plugin).

The WriteableBitmap answer is correct if you just want to capture a partial or complete visual tree rendering of the Silverlight app only.

Jeff Wilcox
yeah, i expect the sandbox should prevent screen grabbers from crawling out the silverlight instance. but i just needed to be able to capture part of my silverlight display, so the other answer works out fine.thanks;
velvet sheen