I have a column of datatype bitmap. the value is composed of a set of icons merged into an image side by side which can vary in numbers. My problem is that when the column is resized the images shrink to fit to the point where no images are visible. How can I prevent this from hapenning? I'd like the image to be truncated instead of resized, only show what fit's in the cell and possibly have a "..." or similar indicator at the end to indicate that not all icons are shown.
Denis_Doiron said:I tried your simplified version. Works great but i prefer the first solution. Because the first one makes the image scale down vertically when the row height is shrinked but not horizontally. The second one simply doesn't scale at all. So i get a very small amount of vertical clipping when shrinking rows on the simplified solution.
Oh, that makes sense. I hadn't thought of that.
Denis_Doiron said: The ellipsis indeed seems trickier, not that the scalling wasn't tricky ;-). What makes it even worse is that I'd really like to be able to leverage what you guys do with text. Where if an ellipsis is shown, a mouse hover on the cell shows the value in a tooltip type control. I would love to show the image in that tooltip.
To do that, you would probably have to make the ImageUIElement less wide so you leave some extra space and then add an some other UIElement that you can use to respond to mouse clicks. You would have to create your own element, I think. Or maybe use the Infragistics UIElementViewer Utility to see what element the editor controls use for their ellipsis button and try to use that element. I'm not sure if that's possible, though, since that element might have dependencies that you don't have here.
I tried your simplified version. Works great but i prefer the first solution. Because the first one makes the image scale down vertically when the row height is shrinked but not horizontally. The second one simply doesn't scale at all. So i get a very small amount of vertical clipping when shrinking rows on the simplified solution.
The ellipsis indeed seems trickier, not that the scalling wasn't tricky ;-). What makes it even worse is that I'd really like to be able to leverage what you guys do with text. Where if an ellipsis is shown, a mouse hover on the cell shows the value in a tooltip type control. I would love to show the image in that tooltip.
Thank you again for incredible support on this. :-)
Okay, that's a bit trickier, but it's certainly possible. First, I realize now that the code I have here is actually more complicated than it needs to be. You can do this, instead:
public void AfterCreateChildElements(UIElement parent) { if (parent is EmbeddableImageRendererUIElement) { ImageUIElement imageUIElement = parent.GetDescendant(typeof(ImageUIElement)) as ImageUIElement; if (imageUIElement != null) { imageUIElement.Scaled = false; } } }
This stops the image from scaling in a much easier way.
To detect if the image is being clipped, you could do this:
if (imageUIElement.ImageRect.Right > parent.Rect.Right)
From this, you can determine how much of the image is cut off and then change the image to a new image with an ellipsis in the right spot. The only problem with this approach is that you will be creating a whole lot of Bitmaps and it will be difficult to make sure they all get properly disposed. But it seems doable.
Thank you!
Works like a charm! Now if only I could get that ellipsis to show. :-)
Okay, I misunderstood the situation. I assumed this was a column with an image and text in it. But it appears that you are creating a dedicated column just for the images and using the cell Value as the image, rather than applying an image to a cell via the Appearance. So the CreationFilter would need to be changed around a bit.
Since this is an image column and not a text column, you need to look for a parent element that is an EmbeddableImageRendererUIElement, instead of EditorWithTextUIElement.
So just change:
if (parent is EditorWithTextUIElement)
to
if (parent is EmbeddableImageRendererUIElement)
And I think everything else will work the same.