- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
跟踪DataGridRow.Item
之后和 DataGridRow.IsNewItem
属性,我发现:每个添加的项目(当 Source 为 ObservableCollection<MyClass>
时添加到 DataGrid), IsNewItem
总是积极的,虽然Item
虽然他不是NewItemPlaceholder
.
后来我看了MSDN并看到它确实受到两个因素的影响:
Gets or sets a value that indicates whether the DataGridRow is a placeholder for a new item or for an item that has not been committed.
我如何提交添加的项目?
最佳答案
您可以完全在 XAML 中与 NewItemPlaceholder
进行比较:
<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 不是 CollectionView.NewItemPlaceholder 之后仍保持为真,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20862356/
我有一个绑定(bind)到列表框的可观察集合。该集合有 2 个项目,但列表框显示 3 个项目(例如,实际上在可观察集合中的 2 个项目和 NewItemPlaceholder 的附加项目。 我希望它只
删除绑定(bind)集合中的所有项目后,datagrid.items.count为1,项目集合中唯一的项目是newitemplaceholder,但datagrid不显示newitemplacehol
我花了几天时间才找到这个简单问题的答案。我想在初始化新行时这样做,然后 NewItemPlaceholder 会立即出现。 NewItemPlaceholder 也称为空白行 - 用于将新项目添加到
我正在开发一个 WPF TabControl,其最后一项始终是添加新选项卡的按钮,类似于 Firefox: TabControl 的 ItemSource 绑定(bind)到一个 Observable
概览 我正在开发一个 WPF 应用程序(使用 .NET 4.5),其中一部分涉及在 DataGrid 中显示一些数据。 用户可以在 DataGrid 中添加新行并通过别处的按钮删除一行。 当用户开始添
这是我的数据模板:
跟踪DataGridRow.Item之后和 DataGridRow.IsNewItem属性,我发现:每个添加的项目(当 Source 为 ObservableCollection 时添加到 DataG
我是一个使用页面的向导式应用程序,用户可以通过 Next 和 Previous 按钮或使用导航栏直接访问某些页面在它们之间导航。 在一页上(我将其称为“网格页”),我有一个绑定(bind)到 Data
我是一名优秀的程序员,十分优秀!