Hi, I have enabled Auto Preview for one of the columns in my grid, and it looks very nice, however, if I hover over it with the mouse I don't get a tooltip displaying the whole text as I would with the column! :( Is there any way to enable this behavior?
Thanks.
Hi Mike, that worked a treat, thanks!
Hi Brian,
Oops, sorry, I should have noticed that. I guess the tracking of the characters is off by default for efficiency.
What you have to do is trap for when the TextUIElement is created and added to the grid. You would do this using a CreationFilter. It's a pretty simple filter in this case:
public class TrackautoPreviewCharactersCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { // Trap for the RowAutoPreviewUIElement. if (parent is RowAutoPreviewUIElement) { // Get it's child TextUIElement and set TrackCharactersRendered TextUIElement textUIElement = parent.GetDescendant(typeof(TextUIElement)) as TextUIElement; if (textUIElement != null) textUIElement.TrackCharactersRendered = true; } } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { // do nothing return false; } #endregion }
So you just set the grid's CreationFilter property to an instance of this class.
I see there is a property in the TextUIElement called IsTextFullyVisible, which looks like what I need, but it's documentation says it needs both TrackCharactersRendered and TrackTextArea to be true for it to work, and in my case TrackCharactersRendered is false. Any ideas how I can set this to true?
I have also been looking at possibly using the MeasureString method to work out the required size for the text, but I need a font for this and the only one I can find is the one from the grid control itself. This seems to work but I suspect it's not right since you can set an appearance for the preview row which can have font data, and therefore a different font. How can I find the font used for this through the TextUIElement?
The TextUIElement class has a property on it called IsTextFullyVisible that should fit your needs.
Hi again, I can now display the tooltip OK, but the tip is always displayed when the mouse is over the preview area, even if all the text fits and is being displayed in the grid. Is there an easy way to determine if the text is being clipped, so that I only display the tip if there is text that can't be seen (just like a celltip). Thanks.