UXWindow GetThumbnail method not working???

3 replies. Last post: December 3, 2010 12:59 PM by Chris Swain
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Chris SwainMember

I'm trying to use the GetThumbnail(bool forceRefresh) method of the UXWindow object to get a thumbnail view of my window objects.  But, for some reason is is returning a 0 pixel image.  What's the trick to make it return a good thumbnail imagesource?

I've tried the UpdateVisualThumbnail() method.  I've even cast the UXWindow to an IWindow and used the Thumbnail property, but nothing works. 

Note:  I'm trying to get the thumbnail in a custom converter.  See the code below:

    public class UXWindowContainerToImageSourceConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is UIElement)
            {
                UXWindow window = GetWindowContainer(value as DependencyObject);
                
                window.UpdateVisualThumbnail();
                
                ImageSource bitmap = window.GetThumbnail(false);
                window.UpdateLayout();
                
                //WriteableBitmap bitmap = new WriteableBitmap(window, null);
                //bitmap.Invalidate();

                return bitmap;
            }
            return value;
        }

        private UXWindow GetWindowContainer(DependencyObject element)
        {
            DependencyObject parent = element;
            while (parent != null && !(parent.GetType().IsSubclassOf(typeof(UXWindow)) || parent is UXWindow))
            {
                parent = VisualTreeHelper.GetParent(parent);
            }

            return parent as UXWindow;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
All times are GMT -5. The time now is 8:36 PM.
Previous Next