BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
public void ExporGridtBtn_Click(object sender, System.Windows.RoutedEventArgs e) { RenderTargetBitmap bmp; BitmapEncoder bitmapEncoder; int width; GanttControl Gantt = this.AssociatedObject.TabControl.SelectedContent as GanttControl; GanttGrid tmp = Gantt.FindName<GanttGrid>("PART_GanttGrid"); ScrollViewer chartGrid = tmp.FindName<ScrollViewer>("PART_ScrollViewer"); Gantt.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Gantt.Arrange(new Rect(new Size(Gantt.DesiredSize.Width, Gantt.DesiredSize.Height))); bmp = new RenderTargetBitmap( (int)Gantt.DesiredSize.Width, (int)Gantt.DesiredSize.Height, 96, 96, PixelFormats.Default); bmp.Render(chartGrid); width = (int)(Gantt.DesiredSize.Width - chartGrid.ActualWidth); CroppedBitmap crpBmp = new CroppedBitmap(bmp, new Int32Rect(0, 0, width, (int)Gantt.DesiredSize.Height)); bitmapEncoder = new PngBitmapEncoder(); bitmapEncoder.Frames.Add(BitmapFrame.Create(crpBmp)); SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.FileName = "Untitled"; saveFileDialog.DefaultExt = "png"; saveFileDialog.Filter = "PNG Files (*.png)|*.png|Jpeg Files (*.jpg)|*.jpg|Bitmap Files (*.bmp)|*.bmp|All files (*.*)|*.*"; saveFileDialog.FilterIndex = 1; if (saveFileDialog.ShowDialog() == true) { using (Stream stream = saveFileDialog.OpenFile()) { bitmapEncoder.Save(stream); stream.Close(); System.Diagnostics.Process.Start(saveFileDialog.FileName); } } }