如何截取完整的屏幕截图 [英] How can I take a screenshot full

查看:28
本文介绍了如何截取完整的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含更多 10 个项目的列表框,我编写了一个代码来在 Windows Phone 8 上对其进行截图和共享,但它只是将所有内容都显示在屏幕上(3 个项目)而不是完整的列表框.如何截取完整的 Lisbox 屏幕截图?这是我的代码.

I have a listbox with more 10 item, and I write a code to screenshot it on Windows Phone 8 and sharing, but it just take everything on display on screen (3 item) not full listbox. How can I take a screenshot full Lisbox? This is my code.

var bmp = new WriteableBitmap(lbxDays, new TranslateTransform());
var width = (int)bmp.PixelWidth;
var height = (int)bmp.PixelHeight;
bmp.Render(lbxDays, new TranslateTransform());
using (var ms = new MemoryStream())
{
    bmp.SaveJpeg(ms, width, height, 0, 100);
    ms.Seek(0, System.IO.SeekOrigin.Begin);
    var lib = new MediaLibrary();
    var dateStr = DateTime.Now.Ticks;
    var picture = lib.SavePicture(string.Format("screenshot"+dateStr+".jpg"), ms);
    var task = new ShareMediaTask();
    task.FilePath = picture.GetPath();
    task.Show();
}

推荐答案

尝试使用此代码为您的控件拍摄快照.将 UIElement 传递给您想要的此方法.希望这能解决您的问题

Try this code for taking snapshot of your control. Pass the UIElement to this method in which you want. Hope this will solve your issue

private WriteableBitmap RenderControlAsImage(UIElement element)
{
    element.UpdateLayout();
    element.Measure(new Size(element.Width, element.Height));
    element.Arrange(new Rect(0, 0, element.Width, element.Height));
    return new WriteableBitmap(element, null);
}

这篇关于如何截取完整的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆