WPF中ListView绑定数据源后居中显示

1<GridViewColumn Header="Name" x:Name="column">
2         <GridViewColumn.CellTemplate>
3                <DataTemplate>
4                         <TextBlock Width="Auto" TextAlignment ="Center" Text="{Binding Path=Name}"  

                                    MinWidth="{Binding Path=ActualWidth,ElementName=column}"/>
5                 DataTemplate>
6          GridViewColumn.CellTemplate>
7 GridViewColumn>


主要就是为TextBlock的MinWidth设置绑定到GridViewColumn的ActualWidth

你可能感兴趣的:(WPF,listview,wpf,datatemplate)