I have the following problem:
I have a plot in one of my Prism views. My goal is to generate report from my application which includes generated OxyPlot chart. I use the following line to save the plot to the image:
plot.SaveBitmap(fileName, 960, 540, OxyColor.FromRgb(255, 255, 255));
The problem occurs when I try to save bitmap without previously see the plot in user interface. In this case I get only the blank plot, white bitmap with correct size but without content. There is no axis, no title (the bitmap is simply blank). When I use function to generate XAML instead of Bitmap, the result is the same: no content at all.
I had also noticed that the plot have both Width and Height set to 0 when plot is saving. Setting this values before Save function does not change the result file.
I have tried following codes just before saving image:
plot.InvalidatePlot();
Or even:
plot.InvalidatePlot();
Action emptyAction = delegate { };
plot.Dispatcher.Invoke(DispatcherPriority.Render, emptyAction);
plot.InvalidatePlot();
When I navigate the user interface that I can see the plot: the save function come back to correct behaviour. There are no exceptions, the plot has my data to plot just before saving.
Please, help...
I've had the same issue using oxyplot. I was trying to export the image to a file, but it was only working when I showed it at the screen first. To make it work you will have to define all the model programatically, and bind the model to the XAML. This way you will not have to pass through the view to export correctly.