0

I would like to know if it is possible to "screenshot" an element without showing it on screen.

For example, this StackPanel:

private void Button_Click(object sender, RoutedEventArgs e)
{
    StackPanel sp = new StackPanel();
    sp.Children.Add(new Button { Content = "Bouton 1" });
    sp.Children.Add(new Button { Content = "Bouton 2" });
    sp.Children.Add(new Button { Content = "Bouton 3" });
    sp.Children.Add(new Button { Content = "Bouton 4" });
    sp.Children.Add(new Button { Content = "Bouton 5" });

    // Take screenshot of sp
}

I don't think this is possible, as there is no rendered size, but I'd like to be sure.

Thanks !

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Shimrod
  • 3,115
  • 2
  • 36
  • 56
  • Take a look: http://stackoverflow.com/questions/5124825/generating-a-screenshot-of-a-wpf-window – Felipe Oriani Jul 16 '13 at 18:42
  • It won't work, as it requires a size. I don't know the size as the element has not been shown. – Shimrod Jul 16 '13 at 18:49
  • 3
    It will work, but you will have to call `Measure` and `Arrange` as shown [here](http://stackoverflow.com/a/14953281/1136211). – Clemens Jul 16 '13 at 19:05
  • Thanks Clemens ! It does work. Do you want to answer the question, so I'd accept your answer ? – Shimrod Jul 17 '13 at 14:49

0 Answers0