Silverlight export image to PNG
Posted: Thu Jun 24, 2010 12:15 am
How can I export the TChart image to a file such as PNG in Silverlight?
I tried the code shown, but no file is produced. Is there sample code somewhere that I have not found?
Thanks,
Kent
I tried the code shown, but no file is produced. Is there sample code somewhere that I have not found?
Thanks,
Kent
Code: Select all
private void buttonCopy_Click(object sender, RoutedEventArgs e)
{
//Stream myStream;
string fileName;
SaveFileDialog saveDialog = new SaveFileDialog();
try
{
fileName = string.Format("Chart Image {0}", string.Format("{0:yyyy-MMM-dd}", DateTime.Now));
//saveDialog.SafeFileName = fileName;
saveDialog.DefaultExt = "png";
saveDialog.Filter = "Chart image file (*.png)|*.png";
saveDialog.FilterIndex = 1;
// saveDialog.Title = "Export Chart Data";
if (saveDialog.ShowDialog() == true)
{
FChartTimeSeries.ChartDisplay.Export.Image.PNG.Save(saveDialog.SafeFileName);
//FChartTimeSeries.ChartDisplay.Export.Image.PNG.Save(myStream);
//using (Stream stream = saveDialog.OpenFile())
//{
// using (StreamWriter writer = new StreamWriter(stream))
// {
// writer.Write(myStream);
// }
//}
}
}
catch
{
}