问题标签 [listcollectionview]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
123 浏览

.net - 有没有办法对列表视图进行排序而不必重新创建其所有元素?

我有一个 listView 显示一堆图表。我可以使用不同的标准对这个列表视图进行排序。不幸的是,当我执行排序时,操作花费的时间比预期的要长,我意识到在触发排序后,所有图表都被重新创建。

我的数据源是一个可观察的集合,视图由一个图表控件和一些标签组成。我使用视图排序描述对视图执行排序,所以排序应该在视图而不是数据源上执行,对吗?

我一直在四处寻找,似乎排序触发了刷新,从控件中删除了 UI 元素并重新创建它们……但这似乎没有必要,因为我只是对 UI 元素的位置进行排序。

有没有办法避免这种刷新行为,只重新排列 UI 元素的位置?

0 投票
0 回答
492 浏览

wpf - 编辑时在WPF中对TreeView的子项进行排序

我有一个 2 级 TreeView,其中填充了一个集合项目,每个项目都有另一个项目集合。

在集合内的集合的情况下,我使用 ListCollectionView 使用转换器对这些项目进行排序,如下所示:

如何在 Xaml 中使用 SortDescriptions 对 TreeView 项目进行排序?

我发现的问题是 ListCollectionView 在编辑项目时不会使用它们,因此我创建了自己的 ListCollectionView 类以附加到项目属性通知。我不知道的是,当我检测到某个项目已更改为使用 ListCollectionView 时该怎么办。如果我在 ListCollectionView 上调用 Refresh(),我会在 TreeView 上丢失选择,我在某处看到过使用 Replace 操作提升 CollectionChangedNotification(这对我来说是个好主意),但它对 TreeView 没有影响。

关于如何在不丢失所有选择和扩展项目的情况下更新 TreeView 排序的任何想法?

谢谢。

0 投票
3 回答
2284 浏览

c# - ListCollectionView does not track the current selected item on a TreeView in WPF

I've done this really simple example, is a Window with a TreeView and a Button. When you click the button you should see the selected item, but is not working, the CurrentItem property does not get updated when you change the selection:

C#:

XAML:

The MSDN documentation says

If the target is an ItemsControl, the current item is synchronized with the selected item

Any idea on why is this not working?

Thanks in advance.

0 投票
1 回答
2108 浏览

wpf - 如何在 wpf 的组标题中显示属性名称

在上面的代码中,我希望显示分组的属性名称。例如 性别 --> 男孩 ; 性别 --> 女孩。

我应该提供什么???????????? 在上面的xml中?

另外,请让我知道是否有任何好的书或链接来解释分组的内部细节ListCollectionView

0 投票
1 回答
842 浏览

apache-flex - 菊花链 ListCollectionView 不反映源集合中过滤器的更改

ListCollectionView 通常被宣传为菊花链相同数据的不同视图的好方法。您有一些源集合,然后使用 ListCollectionView + filterFunction 包装源数据并呈现该源集合的子集。当源集合更改(添加或删除)时,链接的 LCV 会自动更新。但是,如果源集合的 filterFunction发生更改,它似乎不会传播到链接的 LCV:

如果我向 中添加一个新的 Matt 对象sourcejustMatts将获取该更改并按预期重新运行其过滤器。

但是,如果我添加一个过滤器source以排除 Matt 对象,justMatts则不会对源过滤器进行该更改:

在这一点上,我希望 justMatts 收到 aCollectionChangeEvent并重新运行它的过滤器。由于所有的 Matts 都已从source对象中过滤掉,因此justMatts也将是空的。但是,如果您查看ListCollectionView代码,它们不会处理应用新过滤器CollectionEventKind.REFRESH时触发的内容。source我在这里做错了什么(使用错误的类等)还是在 Flex 中不支持source过滤的更改。

我可以通过手动调度CollectionEventKind.RESETon来实现我期望的工作source,但我希望不必对任何东西进行子类化。

0 投票
3 回答
2884 浏览

c# - Edit an entity in a new window in wpf

i have a window that shows a list of entities and i want to edit the selecteitem of gridview in a new window (Not in grid). when i submit my form no error occurred but entity have no changes in database! please help me.

in top of my list window code behind:

and in window_loaded i use this method for fetch data:

Editbutton click event:

all of the above code is in my first window (window that shows a list of entities). and in my second window (window for edit selected item of a first window):

submitbutton click event:

my problem is: when i submit edit form no error occurred but data dont save in database and when i cancel edit form i get this error:

InvalidOperationException was unhandled: CancelEdit is not supported for the current edit item.

0 投票
1 回答
7978 浏览

wpf - 如何创建 WPF ListCollectionView 对 DataGrid CollectionViewSources 进行排序

这是我的 CollectionViewSources:

我目前有以下控件相互提供数据:

我的窗口的 DataContext 是通过一个包含我所有控件的网格提供的:

组合框:

一个列表框:

最后,我试图使其可排序的 DataGrid :(现在只有一列):

到目前为止,我的确切代码是:

我已阅读并理解创建 ListCollectionViews 以处理 CollectionViewSource 中包含的排序属性的重要性,我从博客Bea Stollnitz 的博客中获得了该属性。

但是,我不断收到错误消息 Null Reference Exception Unhandled: “Object reference not set to an instance of the object.”

我该如何处理这个问题?我是否需要进一步定义我的 ListCollectionView,或者我需要建立一个 ICollectionView?我的 PartNum 列包含以数字开头的零件编号,有时还包含字母。标准的排序方向是否适用?

0 投票
2 回答
1125 浏览

wpf - 根据 Group ItemCount 对组进行排序

在 a 上ListCollectionView,我只是添加新的GroupDescriptions. 但我正在寻找一种根据ItemCount组对它们进行排序的方法。

所以在第一个位置,我会得到最多项目的组。

0 投票
4 回答
8577 浏览

c# - 通过 ListCollectionView 的 ObservableCollection 显示不正确的项目列表

C#:

XAML:

ObservableCollection 包含 4 个元素,并且 ListBox 显示所有 4 个,如预期的那样。单击按钮时,ObservableCollection 的第一个元素被删除。然而,ListBox 现在只显示第二个和第三个。似乎第一个和第四个已被删除。

如果该行在(或完全注释掉)之后Models.CollectionChanged += (s, e) => View.Refresh();移动,事情会按预期工作。 View = new ListCollectionView(Models);

为什么?

PS这是一个更大的难题的一个简单部分。在这个小例子中,我意识到我不需要调用View.Refresh();CollectionChanged 来让 ListBox 进行自我更新。

0 投票
1 回答
1007 浏览

datagrid - 无法将 ListCollectionView 插入 Xceed DataGridCollectionViewSource.Source

获取 System.ArgumentException -“System.Windows.Data.ListCollectionView”不是属性“Source”的有效值。

我已将 xceed 数据网格的 ItemsSource 绑定到我的视图模型中的 ICollectionView。有什么办法可以克服吗?