WPF 툴킷의 MS 차트를 PNG로 내보낼 수 없습니다. 다른 포럼의 단계를 밟았지만 모든 후 PNG는 완전히 검은 색입니다. 내가 도대체 뭘 잘못하고있는 겁니까?WPF Toolkit (MS Chart)에서 PNG로 차트를 내보내는 방법. 작동하지 않습니다. 검정색 만 생성합니다.
private void export_graf_Click(object sender, RoutedEventArgs e)
{
if (mcChart.Series[0] == null)
{
MessageBox.Show("there is nothing to export");
}
else
{
RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)mcChart.ActualWidth, (int)mcChart.ActualHeight, 95d, 95d, PixelFormats.Pbgra32);
renderBitmap.Render(mcChart);
Microsoft.Win32.SaveFileDialog uloz_obr = new Microsoft.Win32.SaveFileDialog();
uloz_obr.FileName = "Graf";
uloz_obr.DefaultExt = "png";
Nullable<bool> result = uloz_obr.ShowDialog();
if (result == true)
{
string obr_cesta = uloz_obr.FileName; //cesta k souboru
using (FileStream outStream = new FileStream(obr_cesta, FileMode.Create))
{
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
encoder.Save(outStream);
}
}