1) The first solution is using DX. You can render to the screen using Direct2D and DirectWrite and then save the rendered image to disk using the WIC API. If you are writing a Windows Store app, you can have the user select a destination file using Windows::Storage::Pickers::FileSavePicker. Here you can find a sample program.
For more complete samples about using DX in UWP to render or save images, you can refer here.
2) If you want to use pure c#, win2D is good wrapper for direct2D, which can used to draw image. With the help of RenderTargetBitmap, you can render an arbitrary UIElement into a bitmap. As about RenderTargetBitmap, here is MSDN paper, and here is good sample.
For your case, the code may look like below (You can save to file later):
XAML:
<StackPanel>
<Button Content="Save as image source" Click="SaveImageSource_Click" />
<Grid x:Name="RenderedGrid" Height="500" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<canvas:CanvasControl Draw="CanvasControl_Draw" ClearColor="CornflowerBlue"/>
<Image x:Name="RenderedImage" Stretch="None" />
</Grid>
</StackPanel>
C#:
private void CanvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
args.DrawingSession.DrawEllipse(155, 155, 80, 30, Colors.Black, 3);
args.DrawingSession.DrawLine(155, 155, 180, 180, Colors.Red);
}
private async void SaveImageSource_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap();
await renderTargetBitmap.RenderAsync(RenderedGrid, 500, 500);
RenderedImage.Source = renderTargetBitmap;
}
Please let me know if anything unclear.