I want to save grid, the grid contains Rectangle and InkCanvas.
<Grid x:Name="mainGrid">
<Rectangle Fill="Red" Height="100" Width="100"/>
<InkCanvas x:Name="myCanvas" Height="400" Width="400"
Margin="0,0,10,10"/>
</Grid>
Save method code
StorageFile file = await savePicker.PickSaveFileAsync();
RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap();
await renderTargetBitmap.RenderAsync(mainGrid);
IBuffer pixels = await renderTargetBitmap.GetPixelsAsync();
Guid encoderId = BitmapEncoder.PngEncoderId;
using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
var encoder = await BitmapEncoder.CreateAsync(encoderId, stream);
encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore, (uint)renderTargetBitmap.PixelWidth,
(uint)renderTargetBitmap.PixelHeight, 96, 96, pixels.ToArray());
await encoder.FlushAsync();
}
Now the image saved but it contains rectangle only, InkCanvas strokes are not present in the image and also strokes are disappeared from the output window after saved the image.
Can anyone please suggest me, how to save the panel with the InkCanvas?
Thanks..