我的意思是,我不希望为几列中的行提供alternateRowBackground
<DataGrid
AutoGenerateColumns="False" AlternatingRowBackground="LightBlue" AlternationCount="2"
CanUserResizeRows="False" CanUserResizeColumns="False" CanUserAddRows="false"
CanUserDeleteRows="false" CanUserReorderColumns="false" CanUserSortColumns="false"
FontSize="15" FontWeight="SemiBold" ItemsSource="{Binding Collection}"
SelectedIndex="{Binding SelectedRowIndex, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Grid.ColumnSpan="2" RowHeaderWidth="0"
>
答案 0 :(得分:0)
您可以使用CellStyle
属性为特定列中的单元格设置不同的样式。
<DataGrid AutoGenerateColumns="False" AlternatingRowBackground="LightBlue" AlternationCount="2"
CanUserResizeRows="False" CanUserResizeColumns="False" CanUserAddRows="false"
CanUserDeleteRows="false" CanUserReorderColumns="false" CanUserSortColumns="false"
FontSize="15" FontWeight="SemiBold" ItemsSource="{Binding Collection}"
SelectedIndex="{Binding SelectedRowIndex, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Grid.ColumnSpan="2" RowHeaderWidth="0">
<DataGrid.Resources>
<Style TargetType="DataGridCell" x:Key="WhiteBackgroundCell">
<Setter Property="Background" Value="White" />
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Prop1}" Header="Prop1" CellStyle="{StaticResource WhiteBackgroundCell}" />
<DataGridTextColumn Binding="{Binding Prop2}" Header="Prop2" />
</DataGrid.Columns>
</DataGrid>