In WinRT C# how do I save an offscreen XAML tree using RenderTargetBitmap?

前端 未结 2 1651
盖世英雄少女心
盖世英雄少女心 2021-01-03 00:08

The following code throws a cryptic System.ArgumentException from the RenderAsync method \"Value does not fall within the expected range.\" If on the other hand my Canvas is

相关标签:
2条回答
  • 2021-01-03 00:29

    satur9nine's solution to put the rendered UI tree somewhere behind an opaque foreground seems to be the only supported solution. You could also fiddle with the opacity of the parent element to avoid having it showing up. Another option is to render it yourself with Direct2D or use something like the WinRTXamlToolkit.Composition.Render() methods from WinRT XAML Toolkit.

    0 讨论(0)
  • 2021-01-03 00:49

    WinRTXamlToolkit.Composition namespace has this extension that works. Just call this method:

    await WriteableBitmapRenderExtensions.RenderToPngStream(element);
    
    0 讨论(0)
提交回复
热议问题