I have a simple data control defined as follows
<DataGrid x:Name="ScheduleDataGrid" AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="True" Margin="5" ItemsSource="{Binding ScheduleItems}">
    <DataGrid.Columns>
        <DataGridTextColumn...></DataGridTextColumn>
        ....
        <DataGridTextColumn...></DataGridTextColumn>
    </DataGrid.Columns>
</DataGrid>
I have specified CanUserAddRows="True". As advertised, this puts a blank row at the bottom of the grid for the user to add a new row.
Is there a way to style that new item placeholder independently of the rest of the grid?
Yes it is possible to change that placeholder row.
Take a look at this example I just made.
<Window.Resources>
    <Style TargetType="{x:Type DataGridRow}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding}" Value="{x:Static CollectionView.NewItemPlaceholder}">
                <Setter Property="Background" Value="Yellow"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
</Window.Resources>
<Grid>
    <DataGrid AutoGenerateColumns="False" CanUserAddRows="True" ItemsSource="{Binding List}">
        <DataGrid.Columns>
            <DataGridTextColumn Header="Test" Binding="{Binding Path=Name, Mode=TwoWay}"/>
        </DataGrid.Columns>
    </DataGrid>
</Grid>
That placeholder row will appear with yellow background.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With