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)
FindVisualChild method is not provided by WPF framework, you have to add them. May be you want this:
public static IEnumerable FindVisualChildren(DependencyObject depObj)
where T : DependencyObject
{
if (depObj != null)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
if (child != null && child is T)
{
yield return (T)child;
}
foreach (T childOfChild in FindVisualChildren(child))
{
yield return childOfChild;
}
}
}
}
public static childItem FindVisualChild(DependencyObject obj)
where childItem : DependencyObject
{
foreach (childItem child in FindVisualChildren(obj))
{
return child;
}
return null;
}
Add these methods in some utility class so they can be reuse.