I have one data-grid in my project, and after getting strings into it one part of them can't fit, because they are too long. I want that my text-box columns have fixed size, so I don't wanna use "auto" width property for text-box, but I was wondering: Is there some kind of property that I can use for showing whole string optionally? Like for example: If string is to long show the part of it you can fit, and after that show three dots (...) or some symbol like that. After clicking on three dots show whole value of text-box. Or even showing a whole string after rolling over some text-box.
My data-grid looks like this.
There you can see that some too long string values are cut of.
This is the xaml code of text-boxes in data-grid.
<DataGrid Grid.Column="0" Grid.RowSpan="2" AutoGenerateColumns="False" Height="206" HorizontalAlignment="Left" Margin="12,265,0,0" Name="tabela" VerticalAlignment="Top" Width="556" SelectionChanged="tabela_SelectionChanged" ItemsSource="Binding MyObsCollection">
<DataGrid.Columns>
<DataGridTextColumn Header="Type" Width="120" Binding="{Binding Type}"/>
<DataGridTextColumn Header="MapTo" Width="120" Binding="{Binding MapTo}"/>
<DataGridTextColumn Header="Name" Width="116" Binding="{Binding Name}"/>
</DataGrid.Columns>
</DataGrid>
You can set
TextTrimming
toCharacterEllipsis
on TextBlock to show ellipse in case text is larger than available size.Also, you can show the complete text in
Tooltip
. This is how you do it for oneDataGridTextColumn
: