ListView文本超长自动换行
Posted 棉晗榜
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ListView文本超长自动换行相关的知识,希望对你有一定的参考价值。
核心代码:
<GridViewColumn Header="状态" Width="200">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="Binding E3" TextWrapping="Wrap" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
完整代码
<Window x:Class="WpfSnqkGasAnalysis.WindowGasStepLog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfSnqkGasAnalysis"
mc:Ignorable="d"
Title="处理日志" Height="400" Width="640" Loaded="Window_Loaded" WindowStartupLocation="CenterScreen">
<Window.Resources>
<local:ItemIndexConvert x:Key="itemIndex"></local:ItemIndexConvert>
</Window.Resources>
<Grid>
<ListView x:Name="listView" ItemsSource="Binding " Style="StaticResource ListView1" >
<ListView.View>
<GridView>
<GridViewColumn Header="序号" DisplayMemberBinding ="Binding Converter=StaticResource itemIndex" />
<GridViewColumn Header="时间" DisplayMemberBinding ="Binding Check_time"/>
<GridViewColumn Header="状态" Width="200">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="Binding E3" TextWrapping="Wrap" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="操作人" DisplayMemberBinding ="Binding Check_user_name" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
以上是关于ListView文本超长自动换行的主要内容,如果未能解决你的问题,请参考以下文章