在DataGrid列中添加style样式,设置TextWrapping=Wrap就能换行了,且行高为auto效果才能显示出来
<DataGridTextColumn Header="测试" Width="2*" Binding="{Binding TestValue}"> <DataGridTextColumn.ElementStyle> <Style TargetType="TextBlock"> <Setter Property="TextWrapping" Value="Wrap" /> <Setter Property="Height" Value="auto" /> </Style> </DataGridTextColumn.ElementStyle> </DataGridTextColumn>
时间: 2024-11-17 08:59:15