Is There A Way To Style A WPF DataGrid NewItem Placeholder

北城以北 提交于 2019-11-30 19:53:26

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!