how to change colour of an existing column in datagrid wpf

时间:2016-03-30 09:33:47

标签: c# wpf datagrid triggers styles

I want to change colour of the column already existing in my studentlist Observable collection but with this a new column gets created.

so How can I change color of the column already there in my studentList collection binded to datagrid instead of creating a new column?

     <DataGrid AutoGenerateColumns="true" Height="200" 
              HorizontalAlignment="Left" 
              Margin="290,32,0,0"
              Name="dataGrid2" VerticalAlignment="Top" 
              Width="201"
              ItemsSource="{Binding Path=StudentList}" 
              DataContext="{Binding}" >

        <DataGrid.Columns>   
          <DataGridTextColumn Header="StudentName" 
                            Binding="{Binding Path=StudentName}">
            <DataGridTextColumn.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="Foreground" Value="Blue">

                        </Setter>
                    </Style>
                </DataGridTextColumn.CellStyle>
     </DataGridTextColumn>
        </DataGrid.Columns>
     </DataGrid>

0 个答案:

没有答案