I have created a Grid in WPF with Red background. The Grid contains a transparent Canvas with some fixed size. Now while trying to export the Canvas as Image, I am getting an image with black background. But when there is some color in Canvas (say White or Red), I am getting a proper image. Can anybody please tell me why the image is generating with black background if a Canvas has a transparent color.
Example:
Grid grid = new Grid();
grid.Background = new SolidColorBrush(Colors.Red);
grid.Width = 500;
grid.Height = 300;
Canvas c = new Canvas();
c.Width = 500;
c.Height = 300;
c.Background = new SolidColorBrush(Colors.Transparent);
c.MouseLeftButtonUp += new MouseButtonEventHandler(c_MouseLeftButtonUp);
grid.Children.Add(c);
LayoutRoot.Children.Add(grid);
Inside MouseEvent handler of Canvas, I am saving it as jpg image.