I have a windows service that periodically sends emails with images of ChartView controls. I am having a hard time getting the ChartView to fully render unless I attach it to a window and show the window and then immediately close it. The code is running from a windows service and so this is really not desired.
If I render the control using the following BuildContentStream method then it simply displays the "No data to display message"
MemoryStream BuildContentStream(FrameworkElement visualItem,
var view = visualItem;
Rect(0, 0, width, height));
var rtb =
RenderTargetBitmap(width, height, 96, 96, PixelFormats.Default);
var png =
var memStream =
memStream.Position = 0;
If I attach the control to a window and then do the following then it works correctly.
// The window acts as a visualizer. Can't get it working otherwise
var window =
window.Height = 300;
window.Width = 400;
window.Content = errorItem.View;
window.WindowState = WindowState.Normal;
var stream = BuildContentStream(errorItem.View, 400, 300);
I have also tried the ExportToImage extension without success?
Is it possible to get this working from a windows service without any UI?