问题描述
我有xaml网格控件。在网格内我有InkCanvas和文本框。我想将整个网格转换为图像。但我只得到文本框内容。
I have xaml grid control. and inside grid I have InkCanvas and textbox. I want to convert the whole grid as image. but i am getting only textbox content.
我读过画布控件不适用于RenderAsync。 但我想要的是,将网格控件捕获为缩略图。有没有其他方法可以做到这一点。请帮帮我。
I read canvas control will not work with RenderAsync. But I want is, capture grid control as thumbnail. Is there any alternate way to do this. Please help me.
谢谢,
Pallam Madhukar Windows Phone开发人员
Pallam Madhukar Windows Phone Developer
推荐答案
这是对的限制使用InkCanvas:
This is a limitation for RenderTargetBitmap.RenderAsync to working with InkCanvas:
从
here
"渲染的内容需要在主窗口的可视树中。"这就是为什么canvas不能被这种方法使用。
"The rendered content needs to be in the main window's visual tree." So that is why canvas cannot be used by this method.
另一种方法是使用
Win2D
这是一个简单的文档:
Here is a simple document about it:
http://microsoft.github.io/Win2D/html/M_Microsoft_Graphics_Canvas_CanvasDrawingSession_DrawInk.htm
注意,由于您没有标记您的问题,我不确定您的项目类型。请注意,上述方法仅在Windows 10中受支持。
Note, since you haven't tagged your question I'm not sure about your project type. Please notice the above method is only supported in Windows 10.
顺便说一句,您还可以使用此关键字"Windows 10,UWP,InkCanvas"搜索您最喜爱的搜索引擎和RenderTargetBitmap"。关于如何使用InkCanvas做一个很好的博客。
By the way, you can also search with your favorite search engine with this key word "Windows 10, UWP, InkCanvas and RenderTargetBitmap". There is a good blog about how you can do it with InkCanvas.
祝你好运,
Barry
Barry
这篇关于如何捕获或渲染Canvas元素的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!