Hello,
Welcome to Microsoft Q&A!
I checked your code, I found that you haven't rendered your canvas2
into UI, right?
RenderTargetBitmap could only capture content that in the XAML visual tree. That means that you need to render your Canvas first in your UI. For example, add the canvas2
to your page's root element to make it visible. Then you could add the image and call the RenderAsync
method to capture the content.
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.