问题标签 [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.
c# - 修改一项后更改Expander Header的前景色
大家好
我在修改扩展器的项目后更改扩展器标题的前景色时遇到问题。
这是我已经拥有的 WPF 代码段:
我已经尝试在更改值后刷新我的 ListCollectionView,但性能真的很差。
谢谢你的帮助...
更新:
这是我定义的 WPF 代码段GroupStyle
:
...以及此视图的 ViewModel:
wpf - 当 ListCollectionView 更改时,SelectedItem 正在更新
我正在使用 WPF、MVVM 和实体框架。
我正在使用数据输入应用程序,并且我正在尝试启用取消更改以在我的应用程序中工作。取消更改时,所有值将重置为其原始值。我认为我在 EF 端的所有设置都正确。基本上,如果它们在修改后的列表中,我只是将所有实体设置为不变。
我的问题是当我回到 ViewModel 时,我正在尝试重新设置所有字段和派生属性。最大的烦恼是收藏。我们有多个组合框控件,我们绑定到 ListCollectionView,然后我在视图模型中有一个表示 SelectedItem 的附加属性。当我重置集合时,我只是允许该过程重新启动包括集合在内的所有属性。当我更改集合时,它也会尝试更改选定的属性。这样做的问题是,如果它更改了 selected 属性,则支持实体会使用新值更新(就像用户选择了一个项目一样),并且我在技术上无法取回该值。
当我保存时,我实际上遇到了一个相反的问题。保存后,表单将进入其非编辑模式,并且该值将设置为旧值。在编辑中重新打开表单将加载正确的值。为了解决这个问题,我添加了表单 IsSynchronizedWithCurrentItem=true。但是现在我遇到了反向问题,即在编辑期间值回到旧值。
我目前针对这个问题的解决方法是我保留一个状态变量,该变量表示集合已经被填充。并且它跳过了在重新设置视图模型时重置集合。
c# - ListCollectionView CustomSort 2 条件
我的 ViewModel 中有一个 ListCollectionView,我将它绑定到一个 ListBox。假设我有一个字符串集合,我首先要按字符串长度对它们进行排序,然后按字母顺序。我该怎么做?
目前,我通过实现我自己的 IComparer 类来使用 CustomSort 按长度对其进行排序,但是我该如何做到这一点,以便对于具有相同长度的字符串也按字母顺序排列。
wpf - 如何使用 CollectionView 收听 INotifyDataErrorInfo
我有以下情况:
XAML:
其中 Nodes 是ObservableCollection
包含 ListCollectionView 的自定义:
T
在这种情况下是一个Node
对象,具有许多属性,包括我感兴趣的属性(称为 NodeResults):
和NodeResults
:
ObservableValidatableModelBase
实现INotifyDataErrorInfo
,并将其错误存储在一个名为的集合中errors
:
我想要发生的是让Node
s 中的个人CollectionView
通知,以便它在屏幕上ListView
突出显示无效的个人条目(即具有无效的 a )。NodeResults
我的第一直觉是 Node 需要以某种方式订阅和冒泡NodeResults
'ErrorsChanged
事件,因此类BubbleErrorsChanged
上的方法ObservableValidatableModelBase
- 但这似乎不起作用。
另一种可能性是 - ListView 是否甚至有用于显示验证异常的默认模板?如果没有,这样的事情应该有效吗?(它没有……)
ValidationExceptionToColourConverter
根据错误是否存在,只需返回 Brushes.Red 或 Brushes.White即可Nothing
。
注意:将文本框直接绑定到 Nodes.NodeResults.SomeProperty 可以正常工作,给出我期望的结果。
wpf - 如何在 .Net ItemCollection 中获取 IndexOf 对象
在我的 ViewModel 中,我需要以编程方式移动 WPF DataGrid 中一行的焦点和突出显示。DataGrid 只有一列:
在数据上下文 ViewModel 中:
即使我在 ViewModel 中没有数据字段“descr”的属性,这仍然有效,因为我绑定了 DataGrid 的 ItemSource。
在 ViewModel 中,我可以通过从 View 中传入 ItemCollection 来访问 View DataGrid 的 ItemCollection,如下所示:
回到 ViewModel 中,我像这样加载 DataGrid 项目:
我想保留对 ItemCollection 的强制转换,以便我可以保留该 ItemCollection 的 DataGrid 属性。问题是 ItemCollection 的 IndexOf 方法不起作用。当我尝试通过这样做来查找其中一个类对象项的索引时,我只得到-1。
编辑 ------- 这是方法 try IndesOf 的完整代码
编辑--------------------------------- 这是更简单的方法,但我仍然需要 lambda / filter 表达式的帮助和方法调用
结束编辑 ---------------------
在调试器中,我可以看到 _dgItems 中的类 Objects。如果我这样做,它会起作用。
但是当参数只是一个类Object时IndexOf方法不起作用。我认为问题在于我将 DataGrid 项目转换为 ItemCollection。我需要转换类对象,即。myobject,我从 DataGrid 获得的 ItemCollection 可识别的东西。有解决方法吗?谢谢你。
c# - 将带有列表的对象列表转换为单个列表
我有一个对象列表,其中包含以下对象:
userrolesList
可以有一个或多个userroleobjects
。
我需要将此列表发送到另一个系统,但另一个系统只接受对象列表,例如:
在这种情况下,如果一个用户有 10 个角色,我需要将 10 个不同的对象发送到另一个系统。有什么建议可以让我轻松做到这一点而不影响性能吗?
c# - 将日期分组列表框与数据在同一行
我有一个绑定到名为“Schedules”的 ListCollectionView 的 ListBox。
在我的视图模型中,我只按日期分组(我使用一个 ValueConverter,它只给我一个日期:
是否可以进行分组但将其显示在与其他数据相同的行上?现在你有一个案例:
MyDateTime
-----------------时间 | Sometext
-----------------时间 | Sometext
-----------------时间 | Sometext
MyDateTime2
-----------------时间 | 一些文本
我希望它像这样显示:
我的日期时间 | 时间 | 一些文字
| 时间 | 一些文字
| 时间 | Sometext
MyDateTime | 时间 | 一些文字
| 时间 | 一些文字
| 时间 | 一些文本
wpf - WPF DataGrid dynamic columns based on object type and subtype
I'm building a WPF software to manage a stock of electronics components.
I have the following structure:
Resistor and Capacitor are subtypes of Part.
I'm binding a DataGrid
to an ObservableCollection<Part>
, and using a ListCollectionView
to add filtering and grouping functionality.
What I'm trying to accomplish is when I filter the ListCollectionView
to get only the Resistor
subtype, I want the DataGrid
to update it's columns to show the properties of Resistor
type and it's base class Part
(so I would get the columns Manufacturer, PartNumber, Resistance and Power). At the same time, if I filter the ListCollectionView
to get Capacitor
subtype, the DataGrid
should have the Capacitor
class public properties and the Part
public properties (Manufacturer, PartNumber, Capacitance and Voltage).
Finally, If there's no filtering applied, the DataGrid
would show only Part
properties (Manufacturer and PartNumber).
I tried to use the AutoGenerateColumns=true
but the DataGrid
only shows Part
properties, even if I filter the ListCollectionView
to have only Resistors
. I also tried to change the type of the ObservableCollection
to dynamic
and it didn't work either.
How can I change the DataGrid
columns based on type of the object contained in the ObservableCollection
?
c# - 绑定到 ObservableCollection 有效,但不是 ListCollectionView
我试图让我ListCollectionView
绑定到一个组合框。但是,它似乎只在我绑定到我的ObservableCollection
.
特性:
构造函数:
像这样绑定时:
当我单击组合框中的下拉菜单时,我添加的任何项目SitesCollection
都不会显示。但是,如果我像这样进行绑定:
它工作正常,当我单击下拉菜单时我会看到这些项目。
修复尝试:在将 an 项目添加到 后SitesCollection
,我尝试在 theListCollectionView
和 the上发出属性更改通知ObservableCollection
,但没有任何区别。有任何想法吗?