title: Import a PNG file into Wpf Canvas
body: <p>So, <code>I have imported the canvas into a png file.</code></p>
  
  <p>The code for saving the canvas is:</p>
  
  <pre><code>private void CommandBinding_Executed(object sender, RoutedEventArgs e)
          {
              Rect rect = new Rect(canvas1.RenderSize);
              RenderTargetBitmap rtb = new RenderTargetBitmap((int)rect.Right,
                (int)rect.Bottom, 96d, 96d, System.Windows.Media.PixelFormats.Default);
              rtb.Render(canvas1);
              //endcode as PNG
              Microsoft.Win32.SaveFileDialog dl1 = new Microsoft.Win32.SaveFileDialog();
              dl1.FileName = "Sample Image";
              dl1.DefaultExt = ".png";
              dl1.Filter = "Image documents (.png)|*.png";
              Nullable&lt;bool&gt; result = dl1.ShowDialog();
              if (result == true)
              {
                  string filename = dl1.FileName;
                  BitmapEncoder pngEncoder = new PngBitmapEncoder();
                  pngEncoder.Frames.Add(BitmapFrame.Create(rtb));
  
                  //save to memory stream
                  System.IO.MemoryStream ms = new System.IO.MemoryStream();
  
                  pngEncoder.Save(ms);
                  ms.Close();
                  System.IO.File.WriteAllBytes(filename, ms.ToArray());
                  Console.WriteLine("Done");
  
              }
  
          }
  </code></pre>
  
  <p>Now <code>I want to import an image (png file) back to canvas in my application,</code></p>
  
  <p>i.e. to open a png image into a WPF canvas.</p>
  
  <p>So kindly dump the <code>c#</code> code which can import any image file into the canvas in WPF.</p>