I am working on a datagrid in WPF and I ran into a problem.
When adding a multi-line row to my DataGridTextColumn, the row expands in height to fit the entire text. I want the line height to always remain constant, i.e. Only the first line was displayed.
Does anyone know a solution? It seems to be a fairly simple task, but I could not find anything worthwhile in this matter.
Here is my XAML:
<DataGrid Grid.Row="0" AutoGenerateColumns="False" HorizontalAlignment="Stretch" Name="dgPosts" VerticalAlignment="Stretch" SelectionMode="Single" SelectionUnit="FullRow" ItemsSource="{DynamicResource LogPosts}" CanUserAddRows="False" IsReadOnly="True" GridLinesVisibility="Vertical" RowHeaderWidth="0" Margin="0,0,0,0" CanUserReorderColumns="True" CanUserResizeColumns="False" CanUserResizeRows="False" CanUserSortColumns="True" SelectionChanged="dgPosts_SelectionChanged"> <DataGrid.Columns> <DataGridTextColumn Header="Tidpunkt" Width="120" Binding="{Binding Path=TimeStr}"/> <DataGridTextColumn Header="Posttyp" Width="55" Binding="{Binding Path=PostTypeStr}" CellStyle="{StaticResource CenterCellStyle}"/> <DataGridTextColumn Header="Beskrivning" Width="*" Binding="{Binding Path=Text}"/> </DataGrid.Columns> <DataGrid.RowStyle> <Style TargetType="DataGridRow"> <Setter Property="Background" Value="{Binding Path=Color}"/> <Style.Triggers> <Trigger Property="DataGridRow.IsSelected" Value="True" > <Setter Property="Background" Value="Black" /> </Trigger> </Style.Triggers> </Style> </DataGrid.RowStyle> <DataGrid.CellStyle> <Style TargetType="DataGridCell"> <Setter Property="BorderThickness" Value="0"/> </Style> </DataGrid.CellStyle> <DataGrid.Resources> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/> </DataGrid.Resources> </DataGrid>
Thanks in advance!
source share