-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
DataGridTextColumn should have an attribute that enables text trimming and provides a dynamic tooltip. Example:
<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding People}">
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
<DataGridTextColumn Header="Address" Binding="{Binding Address}" TrimAndProvideTooltip="True"/>
</DataGrid.Columns>
</DataGrid>Motivation
This behavior is ubiquitous in grid-like UI elements throughout Windows OS and other software. Text trimming is a strong UX feature; it communicates to the user that they are not viewing the entire block of text. A tooltip makes it easy to see that full text without adjusting the UI control, which may be difficult or impossible if resizing is disabled.
Many Windows programs have this proposed behavior. Examples in Windows 10 are File Explorer (details view) and Task Manager (Details or Services tab).
There are ways to implement this currently, but neither are very robust. Because DataGridTextColumn does not derive from FrameworkElement, it is not possible to use a style. Could use a DataGridTemplateColumn, but then you have the challenge of recreating the text template that DataGridTextColumn already provides.
Implementation details
These details are based on my experience with the proposed behavior.
- The text trimming employed is CharacterEllipsis, as defined by
TextTrimming.CharacterEllipsis. - The tooltip is enabled only when the text is trimmed.
- The tooltip has a very quick initial show delay.
Alternatives
- Separate text trimming and tooltip behavior:
<DataGridTextColumn Header="Address" Binding="{Binding Address}" TextTrimming="CharacterEllipsis" ShowTooltipIfTrimmed="True"/>