Replies: 1 comment 1 reply
-
|
Use Bounds instead of Width / Height. This will get current size while Width and Height is undefined in your case. Bounds is equivalent to WPFs void RenderToFile(Control target, string path)
{
! var pixelSize = new PixelSize((int) target.Bounds.Width, (int) target.Bounds.Height);
! var size = target.Bounds.Size;
using (RenderTargetBitmap bitmap = new RenderTargetBitmap(pixelSize, new Vector(96, 96)))
{
target.Measure(size);
target.Arrange(new Rect(size));
bitmap.Render(target);
bitmap.Save("Test.png");
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am rendering images from a canvas with different controls within (as children). As far as I tested everything has worked fine except the ToggleSwitch, which does not appear in the renders.
For instance I have this canvas:
Which displays this:

But when I render it, shows the following:

To render the bitmap I am using this code:
Which I got from here: AvaloniaUI/Avalonia.HtmlRenderer#10
I have tested it on the following versions:
Beta Was this translation helpful? Give feedback.
All reactions