WPF DataGridRow.IsNewItem即使在DataGridRow.Item不是NOT CollectionView.NewItemPlaceholder之后也保持为True [英] WPF DataGridRow.IsNewItem Remained True even after DataGridRow.Item its NOT CollectionView.NewItemPlaceholder

查看:162
本文介绍了WPF DataGridRow.IsNewItem即使在DataGridRow.Item不是NOT CollectionView.NewItemPlaceholder之后也保持为True的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

跟踪DataGridRow.ItemDataGridRow.IsNewItem属性后,我发现:每个添加的项(当Source为ObservableCollection<MyClass>时添加到DataGrid), IsNewItem总是积极的,尽管Item尽管他不是NewItemPlaceholder.

After tracking the DataGridRow.Item and DataGridRow.IsNewItem properties, I discover that: each added item (to DataGrid when Source is ObservableCollection<MyClass>), IsNewItem Always positive, Although Item Although he is not a NewItemPlaceholder.

此后,我查看了

Afterwards I looked at MSDN and saw that it was indeed affected by two factors:

获取或设置一个值,该值指示DataGridRow是新项目还是尚未提交的项目的占位符.

如何提交添加的项目?

推荐答案

您可以完全在XAML中与NewItemPlaceholder进行比较:

You can do the comparison against NewItemPlaceholder purely in XAML:

<DataTemplate.Triggers>
    <DataTrigger Binding="{Binding Item, RelativeSource={RelativeSource FindAncestor, AncestorType=DataGridRow}}"
                 Value="{x:Static CollectionView.NewItemPlaceholder}">
        <Setter TargetName="Text" Property="Visibility" Value="Hidden" />
    </DataTrigger>
</DataTemplate.Triggers>

这篇关于WPF DataGridRow.IsNewItem即使在DataGridRow.Item不是NOT CollectionView.NewItemPlaceholder之后也保持为True的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆