title: C# Take screenshot of WPF application
body: <p>I have WPF application in which we wanted to achieve functionality of screenshot using code behind.</p>
  
  <p>Whenever we want we should be able take screenshot of our application on user's machine (not entire print-screen)</p>
  
  <p>For this I done some google and found that <code>DllImport("user32.dll")</code> will help me in this regards. However, I don't have any clue how to use this? Which method I should refer here?</p>
  
  <p>I tried with below code but no luck-</p>
  
  <pre><code>[DllImport("User32.dll")]
  public static extern int SetForegroundWindow(IntPtr point);
  Process p = Process.GetCurrentProcess();
  p.WaitForInputIdle();
  IntPtr h = p.MainWindowHandle;
  SetForegroundWindow(h);
  SendKeys.SendWait("k");
  IntPtr processFoundWindow = p.MainWindowHandle;
  </code></pre>
  
  <p>Please suggest. </p>