title: Universal Windows InkCanvas strokes disappear on RenderTargetBitmap.RenderAsync
body: <p>I try to render the strokes of a InkCanvas to a RenderTargetBitmap in a windows 10 universal App. Here is my xaml code:</p>
  
  <pre><code>&lt;Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="*"/&gt;
          &lt;RowDefinition Height="10" /&gt;
          &lt;RowDefinition Height="*" /&gt;
          &lt;RowDefinition Height="Auto" /&gt;
      &lt;/Grid.RowDefinitions&gt;
  
      &lt;Grid x:Name="container"&gt;
          &lt;Rectangle Fill="LightBlue" /&gt;
          &lt;InkCanvas x:Name="InkCanvas" /&gt;
      &lt;/Grid&gt;
  
      &lt;Image Grid.Row="2" x:Name="TheImage" /&gt;
  
      &lt;Button Grid.Row="3" Content="CopyToRendertargt" Click="Button_Click" /&gt;
  
  &lt;/Grid&gt;
  </code></pre>
  
  <p>And here is my code to set the Image.Source property:</p>
  
  <pre><code>public sealed partial class MainPage : Page
  {
      public MainPage()
      {
          this.InitializeComponent();
          InkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse;
      }
  
  
      private async void Button_Click(object sender, RoutedEventArgs e)
      {
          RenderTargetBitmap renderTarget = new RenderTargetBitmap();
  
          await renderTarget.RenderAsync(this.container);
  
          this.TheImage.Source = renderTarget;
      }
  
  }
  </code></pre>
  
  <p>When i click to button the strokes i made on the InkCanvas disappear and the InkCanvas is forzen until i resize the app window. The strokes are not getting rendered to the RenderTargetBitmap. The Image shows just the LightBlue Rectangle.</p>
  
  <p>Does sombody have a solution for this?</p>
  
  <p>** UPDATE **</p>
  
  <p>For those who are searching for the right way to save strokes to a bitmap on uwp. I found the UWP-way of saving InkCanvas Strokes to a Bitmap: The <em>InkStrokeContainer</em> Object has a method called <em>SaveAsync(...)</em> which saves the strokes to a stream. If you use this stream as source for a Bitmap you get the strokes as Bitmap.</p>
  
  <pre><code>        InkStrokeContainer container = TheInkCanvas.InkPresenter.StrokeContainer;
          WriteableBitmap bmp;
          using (InMemoryRandomAccessStream ims =
              new InMemoryRandomAccessStream())
          {
              await container.SaveAsync(ims);
              bmp = await new WriteableBitmap(1, 1)
                  .FromStream(ims, BitmapPixelFormat.Bgra8);
          }
  </code></pre>
  
  <p>*Note: WriteableBitmapEx is used in this sample code (<a href="https://www.nuget.org/packages/WriteableBitmapEx/" rel="nofollow noreferrer">https://www.nuget.org/packages/WriteableBitmapEx/</a>)</p>