如何在Silverlight中捕获部分屏幕

unk*_*own 3 silverlight screenshot

我想从应用程序中执行正在运行的silverlight 3应用程序的屏幕截图,然后我想将其作为缩略图呈现给用户,比如在Image控件中.

我在做梦吗?

Rya*_*yan 5

对于一个简单的页面:

<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>
Run Code Online (Sandbox Code Playgroud)

使用事件处理程序:

    private void btnCapture_Click(object sender, RoutedEventArgs e)
    {
        WriteableBitmap bmp = new WriteableBitmap(LayoutRoot, null);
        this.imgThumbnail.Source = bmp;
    }
Run Code Online (Sandbox Code Playgroud)