问题标签 [wpfdatagrid]
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.
wpf - WPF DataGrid load issue
First off I have a datagrid on the main form which is populated with about 7000 rows. It is bound (to ItemsSource) in the forms constructor. Everything runs extremely fast and smooth when the app loads (less than 1 sec). However when I want to load that same datagrid in another window it takes > 1 min. There is no difference in the xaml between pages. What could be causing this. I am using Virtualizing Stack panel as well as turning on Cell and Row Virtualization on the DataGrid. I have profile my Sql Server and the query runs in the same time for both calls so it's not a database issue.
I got curious and set up a listview and bound it to the same source on the second form and the same scenario happens as well.
What could be the issue?
wpf - DataGridCell.IsEditMode?
我如何知道 DataGridCell 当前是否处于编辑模式(不是 IsSelected),我的意思是,例如单击 DataGridTextColumn 单元格时,它会变成 TextBox 而不是 TextBlock,这就是我所说的 IsEditMode。我想为此模式设置一个触发器设置器。
编辑: 我尝试为 DataGridCell.IsEditing 设置一般样式,但它似乎没有做任何事情。
这是我当前代码的片段:
谢谢。
wpf - 使 WPF 数据网格上的单个复选框不可见
我有一个数据网格绑定到我的视图模型中的 CollectionViewSource 视图。数据网格有一个 CheckBoxColumn 和三个 TextColumn,每个都绑定到视图中项目的属性。我在视图项中还有一个布尔属性“已启用”,我想用它来使各个行中的复选框不可见。作为额外的奖励,也可以更改这些行的其他三列的前景色。但主要的是不要让用户选中启用 == false 的行中的复选框。
编辑:基于下面斯蒂芬和安德鲁的链接,我试图添加一个值转换器,如下面的代码所示。但由于某种原因,它不起作用。我现在正在一个 CollectionView 视图上进行测试,该视图有 90 个项目,其中除一个项目之外的所有项目的 Enabled 属性为 false。所以我期待 89 行带有不可见的复选框和 1 行带有可见的复选框。但是,所有 90 行都有可见的复选框。有任何想法吗?
c# - WPF DataGrid - 通过代码的动态行详细信息
当用户在网格之外执行操作时,我需要在 WPF DataGrid 中显示 RowDetails。但问题是,我需要能够准确地切换 RowDetails 将基于此的内容。例如,如果单击添加,我想在 AddRowDetailControl 类型的 Row 下方显示 RowDetails,如果他们选择编辑,我希望在同一行下显示不同的控件。这可能吗?
c# - 在自定义行模板中导致行选择 - MS WPF DataGrid
我有一个自定义行模板来显示一些数据,它没有在其模板中使用 SelectiveScrollingGrid。我不介意处理我的外部元素上的事件,但我似乎无法弄清楚如何导致“选择”行为。通常,我是通过在活动 DataGridCell 上引发 MouseLeftButtonDownEvent 来引起它的,但是现在我实际上没有任何 DataGridCell,我对如何仅访问 DataGridRow 来复制该行为感到有些困惑。
wpf - 为什么 ListCollectionView.CustomSort 这么慢?
我有一个ObservableCollection
位于 WPF 中的 ViewModel DataGrid
。具有DataGrid
三列:
- 职位栏;这是在运行时由一个显示行在我的 DataGrid 中的位置的 UserControl 呈现的
- 名称栏;这是在运行时由显示列名称的 UserControl 呈现的(是的,我需要一个 UserControl,这取决于名称需要如何显示,但这是一个旁白)
- 数据栏;这是在运行时由另一个 UserControl 呈现的。
我的列定义如下:
因此,因为我的 Row 和 Name 列是 UserControls,所以 WPFDataGrid
不能对它们进行本地排序。所以为了方便排序,当点击一个列标题时,我做了一些ListCollectionView.CustomSort
魔术。
这是我的“名称”列的自定义排序器的样子:
问题是这非常慢。我不知道为什么。在 10 项中DataGrid
,我的应用程序在使用时会停止 3-4 秒。我认为ListCollectionView.CustomSort
应该是最有效的排序方式ObservableCollection
......我哪里出错了?
wpf - 如何将 WPF Datagrid itemssource 绑定到 Collection of Collections?
将 WPF DataGrid ItemsSource 绑定到 ObservableCollections 的 ObservableCollection 的最佳方法是什么?
例如
MyDataItem 可能如下所示:
我可以假设集合的集合不是锯齿状的,它们都包含相同数量的“列”
是否可以将每列动态绑定到 MyDataItem 对象的“DataValue”属性,还是需要将数据打包到更容易绑定的结构中?
wpf - 如何显示 wpf 工具包数据网格的行索引?
我只想在 wpf 工具包中添加一个索引列DataGrid
来显示DataGrid
. 如何?
wpf - 一一着色 WPF DataGridRows
我正在制作一个 WPF 程序,它能够DataGrid
使用循环将行逐一着色为红色for
,但我遇到了一些奇怪的事情。如果DataGrid
数据库表中的数据超过 40 行,它不会为所有行着色。
这是我正在使用的代码。
有没有其他方法可以通过其他方法对行逐个着色,或者这是 wpftoolkit 中的某种错误?
wpf - WPF DataGrid: how do I stop auto scrolling when a cell is clicked?
Problem:
If my DataGrid
is not entirely visible (horizontal & vertical scrollbars are showing) and I click on one of my cells that is partially visible, the grid auto-scrolls to bring that cell into view. I don't want this to happen. I've tried playing around with RequestBringIntoView
, like this:
But that does nothing.
Things I've tried:
- My cells are custom
UserControls
; I tried putting an event handler forRequestBringIntoView
on allUserControls
that make up my cells, and tried handling the event, thinking that maybe I wasn't doing enough by just handlingRequestBringIntoView
on theDataGrid
itself. This did not work. - Hosted the
DataGrid
inside of aScrollViewer
, and handled theScrollViewer
'sRequestBringIntoView
event. This actually works, and stops the auto-scrolling behavior, but in my case hosting aDataGrid
inside of aScrollViewer
is not at all desirable, so I need to come up with a different solution.
I'm not sure how to stop this behavior, any ideas?