问题标签 [datagridtemplatecolumn]

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 回答
1906 浏览

c# - Dynamic DataGrid columns in WPF DataGrid based on the underlying set of data (and their type)

I've got kind of a conceptual question. I am in the process of wrapping some statistics classes I wrote into WPF.

For that I have two DataGrid(-Views, currently in WinForms). In one DataGrid each row represents a column in the other. There I can set-up different variables (as in mathematical/statistical variables) with fields like "Header", "DataType", "ValidationBehaviour", "DisplayType". There I can also set-up how it should be displayed. Some Columns can automatically be set to ComboBoxColumns, some TextBoxColumns, and so on and so forth.

So, now once I've set-up these Columns I can go to the other grid and enter my data. I may, for instance, have generated (in grid 1) one Column called "Annual Gross Salary" with input of numerical values. Another Column called "Education" with "0=NoEducation", "1=College Level", "3=Universitary" etc. These labels are displayed as text in the combobox and my statistics engine behind then selects the respective value (0-3) for calculations (i.e. ordinal, nominal variables).

Sooo. In WinForms I could basically generate all the columns by hand in code and then add my data in the respective cells/rows. Now in WPF I thought that must be easy to realise. However, yesterday I got started with ICustomPropertyDescriptor which (maybe I was too thick) didn't give me the results I was looking for.

Basically, I just need to be able to dynamically generate columns (and rows) with different Layout, Controls (ComboBox, simple Input, DateTimes) based on the data that I have. But I don't really know how to go about it?

So here in summary:

  • DataGrid 1

    • Purpose is to display columns that have been specified in DataGrid 2
    • In rows, the user can add any kind of data in the rows below the columns that is allowed as to the columns specifications
  • DataGrid 2

    • Each row in this grid represents a column in DataGrid 1
    • Contains fields like Name/Header, DataType, Validation Behaviour, Default Value, Data Formatting, etc.
    • Also contains a function to be able to set-up how it should be displayed. The user can select from, for instance, ComboBoxColumn (and also add the available options), DateTime, normal TextBox, CheckBox etc.
    • After finishing adding a row it will automatically appear as a new column in DataGrid 1

I'd appreciate any kind of pointer into the right direction. Thanks very, very much in advance! :)

0 投票
1 回答
3401 浏览

wpf - WPF DataGridTemplateColumn 共享模板?

嗨,我有一个数据网格,它有许多相同的 datagridtemplate 列,除了它们在模板的堆栈面板上都有不同的数据上下文。

我想让每一列都使用一个特定的项目模板(就像我对列表框所做的那样),但除非我遗漏了一些东西,否则我似乎看不到如何做。

0 投票
1 回答
2577 浏览

silverlight - Silverlight DataGridTemplateColumn 与 DataGridTextColumn

为什么这个工作...

但这并不...

我得到第二个'System.Windows.Markup.XamlParseException:AG_E_PARSER_BAD_PROPERTY_VALUE'。该问题仅适用于前台转换器,绑定很好。

0 投票
1 回答
2193 浏览

silverlight - Silverlight 4数据网格和选择组标题复选框时选择所有复选框

我有一个分组打开的数据网格,其第一个列是复选框。我希望在组级别上有复选框,以便用户单击一个复选框,它会自动选择该组下的所有复选框,反之亦然。

我还有一个打印按钮,当按下该按钮时,它应该具有选中 CheckBox 的所有行的数组

我怎样才能做到这一点?任何回应将不胜感激

0 投票
2 回答
3063 浏览

silverlight - 具有 CellTemplate 和绑定的自定义 DataGrid 列

我需要使用自定义 CellTemplate 创建一个可重用的 DataGrid 列。除其他外,此 CellTemplate 应包含一个 TextBlock 控件,我需要将值绑定到该控件以在 DataGrid 中显示。到目前为止,我看到的所有示例在 DataGrid 的 Columns 属性中使用列时直接为列指定了 CellTemplate,并且还直接指定了到 TextBlock 的绑定,例如:

我需要将此列封装到一个单一的、可重用的控件中,并且我想为它指定一个绑定,就像为一个普通的 DataGridTextColumn 一样。换句话说,当使用这个自定义列时,我只想写这样的东西:

问题是我的自定义列继承自的 DataGridTemplateColumn 没有 Binding 属性。我以为我可以使用 DataGridBoundColumn,但无法为其指定 CellTemplate。

如何实现期望的行为?谢谢!

0 投票
1 回答
1315 浏览

wpf - 当 WPF RichTextBox 的 EditingCommands 未放在工具栏中时,它们会失去其绑定

在DataGridDataGridTemplateColumn中使用以下代码,我的格式化按钮被禁用(灰显)。格式化按钮仅在放入 ToolBar启用

当按钮放在ToolBar中时,我不需要CommandTarget。因此,当我将它们放在 ToolBar 之外时,有些人可能会认为它必须与 CommandTarget 一起使用,但事实并非如此,为什么?

0 投票
2 回答
2132 浏览

asp.net - ASP.NET:在 DataGrid 的 TemplateColumn 中声明的访问控件

ASCX 文件:

后面的代码:

  • 在后面的代码中,FindControl 返回的 Control 是 null。为什么?

  • 如何访问 buttonMoveUpFormField 和 buttonMoveDownFormField 控件?

  • 从后面的代码中,是否可以访问在 DataGrid 的 TemplateColumn 部分的 ItemTemplate 部分中声明的控件?

0 投票
2 回答
4426 浏览

wpf - 绑定到 DataGridTemplateColumn

我有一个用户表,并且我有一个来自 Book 表的该表的外键。FK 是 ProxyResponsibleUser_ID。当我在 DataGrid 中使用 DataGridTextColumn 时,一切正常,但现在我想使用 DataGridTemplateColumn 为具有 ProxyResponsibleUser_ID 的相应用户显示用户表中的 FullName 列。我收到一个错误,因为 DataGridTemplateColumn 没有 Binding 属性。

那么,我将通过 DataGridTemplateColumn 的哪个属性绑定 ProxyResponsibleUser_ID?提前致谢。

0 投票
1 回答
750 浏览

wpf - WPF DataTemplateColumn 访问 DataTemplate 并设置 ItemsSource

我知道我在做什么很奇怪,但我希望它能够工作。我感觉有些不对劲。

我的资源中定义了一个 DataTemplate,如下所示:

我在我的 xaml 中定义了一个 DataGrid,它有一个加载的事件。

在我的事件处理程序代码中,我想设置在我的 DataTemplate 中定义的 ItemsControl 的 ItemsSource。我背后的代码如下所示:

0 投票
6 回答
17464 浏览

c# - WPF DataGrid:在 DataGridTemplateColumn 上自动重新排序

在 WPF 的 DataGrid 控件中,如果将列设置为默认列类型之一(如 DataGridTextColumn 或 DataGridCheckBoxColumn),对该列进行排序,然后更改其值,网格将自动重新排序。

但是,如果您使用 DataGridTemplateColumn(并允许对列进行排序),则可以对其进行排序,但是更改此列中单元格的值不会导致网格不重新排序。我怎样才能哄它自动触发重新排序?

XAML:

捆绑:

这是我的项目类,以防万一: