I have found and modified following code in order to export my dataGrid to a pdf document using iTextSharp class.
private void ExportToPdf(DataGrid grid)
Also a common practice is to use these methods (posted by Rohit Vats) as extension methods, like this:
static class Utils
{
public static IEnumerable FindVisualChildren(this DependencyObject depObj)
where T : DependencyObject
{
...
}
public static childItem FindVisualChild(this DependencyObject obj)
where childItem : DependencyObject
{
...
}
}
And then in your code:
using Utils;
class MyCode
{
public static DataGridCellsPresenter GetPresenter(DataGridRow row)
{
return row.FindVisualChild();
}
}