Re positioning canvas control

前端 未结 1 327
轻奢々
轻奢々 2021-01-29 09:47

I have Grid with three columns and layout is like

radio button | Canvas Control | radio button

For some feature of my application I need to take a screenshot of

相关标签:
1条回答
  • 2021-01-29 10:21

    You may avoid the layout problem by using an intermediate DrawingVisual:

    var renderTargetBitmap = new RenderTargetBitmap(
        (int)canvasControl.ActualWidth, (int)canvasControl.ActualHeight,
        96, 96, PixelFormats.Default);
    
    var visual = new DrawingVisual();
    
    using (var dc = visual.RenderOpen())
    {
        dc.DrawRectangle(
            new VisualBrush(canvasControl),
            null,
            new Rect(0, 0, canvasControl.ActualWidth, canvasControl.ActualHeight));
    }
    
    renderTargetBitmap.Render(visual);
    
    0 讨论(0)
提交回复
热议问题