积极答复者
win8.1 如何实现把一个page变成图片

问题
答案
-
你好,
可以使用RenderTargetBitmap(8.1的新内容)来实现对控件的截图,不过你需要后台先实例化这个页面,然后对Page控件截图,操作起来可能比较麻烦。
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- 已标记为答案 lxd_DD 2014年7月17日 3:09
全部回复
-
你好,
可以使用RenderTargetBitmap(8.1的新内容)来实现对控件的截图,不过你需要后台先实例化这个页面,然后对Page控件截图,操作起来可能比较麻烦。
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- 已标记为答案 lxd_DD 2014年7月17日 3:09
-
你好 lxdhuainan,
应该不是高度和宽度的问题,而是RenderTargetBitmap这个方法只能对可视的UIElement进行截图,我这里有一个解决方案。
你需要在Page中添加一个Frame,名字叫ScenarioOutput,同时有一个Image用来陈放对应的截图:
private async void Button_Click(object sender, RoutedEventArgs e) { ScenarioOutput.Navigate(typeof(BasicPage1)); RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(); await renderTargetBitmap.RenderAsync(ScenarioOutput); RenderedImage.Source = renderTargetBitmap; ScenarioOutput.Visibility = Windows.UI.Xaml.Visibility.Collapsed; }
对应的截图如下,蓝框为我们截图的结果,你可能需要自己改一下参数什么的。
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later. -
那这样的话,除非你在Frame里加载page的时候也一并把grid加载了,要不然应该没法做实时截图。
或者你是否考虑过使用静态图片来代替,因为GirdView的数据项的尺寸也不大。
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.