2011-02-28 62 views

回答

1

嘗試設置HorizontalContentAlignment到綿延GridViewColumnHeader

<ListView ...> 
    <ListView.Resources> 
     <Style TargetType="{x:Type GridViewColumnHeader}"> 
      <Setter Property="HorizontalContentAlignment" Value="Stretch" /> 
     </Style> 
    </ListView.Resources> 
    <!--...--> 
</ListView> 

然後你可以HeaderTemplate中看起來是這樣的,如果你想在TextBlock爲中心。 否則只是刪除HorizontalAlignment

<DataTemplate> 
    <Grid> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="Auto"/> 
      <ColumnDefinition Width="*"/> 
     </Grid.ColumnDefinitions> 
     <Image Grid.Column="0" .../> 
     <TextBlock Grid.Column="1" HorizontalAlignment="Center" .../> 
    </Grid> 
</DataTemplate>