FindVisualChild reference issue

前端 未结 2 727
既然无缘
既然无缘 2020-12-03 19:40

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)
           


        
2条回答
  •  没有蜡笔的小新
    2020-12-03 20:10

    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();
        }
    }
    

提交回复
热议问题