Back to blog

WPF C# website thumbnail

February 26, 2008 - Posted in Code , College Posted by:

Tags: , , , , , ,

For my FYP (Final Year Project in College) I needed to take thumbnails of web pages and I couldn’t find a solution online that worked. There was only one entry I could find in relation to it and that didn’t seem to work either, but did give me an idea. I looped through the contents of the frame, putting each ‘control’ item to string and then took an image of the contents of that control. I’ll stick up a demo project if anyone asks, but here is important part:

 

Window2 w2 = new Window2();

        void TheFrame_ContentRendered(object sender, EventArgs e)

        {

      

            for (Visual v = TheFrame; v != null; v = VisualTreeHelper.GetChild(v, 0) as Visual)

            {

               

                if (v.ToString().Contains(“WebBrowser”))

                {

                   

                    w2.Image.Source = new DrawingImage(VisualTreeHelper.GetDrawing(v));

                    w2.Show();

                    break;

                }

            }

 

           

 

        }

Feel free to use!!!

Leave a Reply

Your email address will not be published. Required fields are marked *