title: Why can not Grid cloned with childrens?
body: <p>Why can not grid cloned with childrens? The following error occurs on the line <code>Grid1 = Markup.XamlReader.Load(xmlReader)</code>: </p>
  
  <blockquote>
    <p>System.Windows.Markup.XamlParseException: no matching constructor
    found on type System.Windows.Media.Imaging.WriteableBitmap.</p>
  </blockquote>
  
  <p>What needs to be changed?</p>
  
  <pre><code>Private Sub pelespausti(sender As Object, e As MouseButtonEventArgs) Handles Grid1.MouseDown
      If e.LeftButton = MouseButtonState.Pressed Then
          If im IsNot Nothing Then
              If e.GetPosition(im).X &gt;= im.Margin.Left AndAlso e.GetPosition(im).X &lt; im.ActualWidth AndAlso
              e.GetPosition(im).Y &gt;= im.Margin.Top AndAlso e.GetPosition(im).Y &lt; im.ActualHeight Then
                  'CType(bi.PixelWidth / 8, Integer)
                  Dim pix As PixelFormat = PixelFormats.Rgba64
                  Array.Resize(Of Byte)(pixels2, bi.PixelWidth * bi.PixelHeight * Math.Ceiling(pix.BitsPerPixel / 8))
  
                  colors = New List(Of System.Windows.Media.Color) From {System.Windows.Media.Colors.Transparent}
                  palete = New BitmapPalette(colors)
                  bi2 = BitmapSource.Create(bi.PixelWidth, bi.PixelHeight, 96, 96, pix, palete, pixels2, Math.Ceiling(bi.PixelWidth * pix.BitsPerPixel / 8))
  
                  o = New FormatConvertedBitmap(bi2, pix, palete, 100)
                  o2 = New FormatConvertedBitmap(bi, o.Format, palete, 100)
                  Dim pixelsp(Math.Ceiling(o2.Format.BitsPerPixel / 8)) As Byte
                  Dim pixelsp2(Math.Ceiling(o2.Format.BitsPerPixel / 8)) As Byte
                  o2.CopyPixels(New Int32Rect(e.GetPosition(im).X, e.GetPosition(im).Y, 1, 1), pixelsp, Math.Ceiling(o2.Format.BitsPerPixel / 8), 0) 'klaida
  
                  ras = New WriteableBitmap(o)
                  'Me.Title = Color.FromArgb(pixelsp(0), pixelsp(1), pixelsp(2), pixelsp(3)).R
                  Dim m As Boolean = True
                  For x = 0 To o2.PixelWidth - 1
                      For y = 0 To o2.PixelHeight - 1
                          o2.CopyPixels(New Int32Rect(x, y, 1, 1), pixelsp2, Math.Ceiling(o2.Format.BitsPerPixel / 8), 0)
                          For k = 0 To pixelsp.GetUpperBound(0)
                              If Not pixelsp(k) = pixelsp2(k) Then
                                  m = False : Exit For
                              End If
                          Next
                          If m = True Then
                              ras.WritePixels(New Int32Rect(x, y, 1, 1), pixelsp2, Math.Ceiling(o.Format.BitsPerPixel / 8), 0)
                          Else
                              m = True
                          End If
                      Next
                  Next
                  im.Source = ras
  
                  Me.Title = "komp"
              End If
          End If
          Dim objXaml As String = Markup.XamlWriter.Save(Grid1)
          Dim StringReader As StringReader = New StringReader(objXaml)
          Dim xmlReader As Xml.XmlReader = Xml.XmlReader.Create(StringReader)
          Grid1 = Markup.XamlReader.Load(xmlReader)'here exception
          End If
  End Sub
  </code></pre>