iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
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(); } }
Based on my test, the method runs without any issue on button click event handler.
After discussing this issue with the developer, it seems the method will always return empty image under custom converter because in the converter state the window will not be displayed.
Thanks. I came up with the solution by monitoring the LayoutUpdated event of the window and doing some checking to see if a thumbnail needs to be generated. If so, then I call the GetThumbnail method and assign the imagesource to my taskbar sub-item. I'm sure I'll need to do more optimization, but it's working.
I came up with a better answer, I think.
I'm attaching to the ItemBound event of the UXDesktopDock control.
In the event handler, I'm attaching to the StackOpened event of the UXDesktopDockButton item that was just bound.
In the StackOpened event handler, I'm looping through the Items collection and using the bound data to build a window name string to be used by the UXDesktop.FindWindow(windowName) method to get the associated window.
Then I call the GetThumbnail(false) method to get the thumbnail imagesource and assign it to a property of my bound data item called Thumbnail.
End result - When the stack of instance items is opened from my UXDesktopDockButton, I find the associated window for each UXStackItem, get the thumbnail, and set the Thumbnail property for the data item in the DataContext of the UXStackItem.
This ensures that I get the latest thumbnail to show every time I display the task bar instance items.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname