黔东南·清风
2021-10-24 16:24
采纳率: 100%
浏览 121

C# WPF ListView控件如何指定某列数据居中显示

如题!刚学C#
网上搜了一下有教程,但是按照教程写的会让整个ListView数据居中显示,我想就指定某一列的数据居中显示该怎么写。

img

<ListView x:Name="ListView_Watermark" HorizontalAlignment="Left" Height="423" Margin="10,10,0,0" VerticalAlignment="Top" Width="908">
  <ListView.ItemContainerStyle>
      <Style TargetType="{x:Type ListViewItem}">
           <Setter Property="HorizontalContentAlignment" Value="Center"/>              
       </Style>
  </ListView.ItemContainerStyle>
        <ListView.View>
             <GridView>
                    <GridViewColumn Header="序号" Width ="60" DisplayMemberBinding ="{Binding Number}"/>
                    <GridViewColumn Header="文件名" Width="650" DisplayMemberBinding ="{Binding FileName}"/>
                    <GridViewColumn Header="页数" Width="80" DisplayMemberBinding="{Binding Pages}"/>
                    <GridViewColumn Header="文件大小" Width="90" DisplayMemberBinding ="{Binding FileSize}"/>
          </GridView>
  </ListView.View>
</ListView>

1条回答 默认 最新

相关推荐 更多相似问题