如何在Silverlight中捕获部分屏幕

时间:2010-03-19 05:24:47

标签: silverlight screenshot

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

我梦想着吗?

2 个答案:

答案 0 :(得分: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>

使用事件处理程序:

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

答案 1 :(得分:0)

如果您想要进行真正的屏幕捕获(在插件之外),您正在梦想。

如果您只想捕获Silverlight应用程序的部分或完整可视树渲染,则WriteableBitmap答案是正确的。

相关问题