- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在制作如下图所示的 UI。
它是一个DataGrid,Itemsource 绑定(bind)到一个List。我无法为 TextBox
设置 ColumnSpan
。首先,我尝试使用 UserControl
但我无法修复 DataGridTemplateColumn header ,然后我尝试了 DataGridTemplateColumn.CellTemplate 但无法设置 ColumnSpan
。
有什么办法/方法可以制作这种Datagrid吗?
提前谢谢你。
最佳答案
在 DataGrid
中没有 ColumnSpan
,就像在普通的 Grid
中一样。
要获得这种布局,您有 3 种选择,不幸的是,它们都有严重的缺点。
使用合并事件在代码隐藏中将单元格合并在一起。 See a guide to this here这需要后面有一大块代码 编码以使您的布局正确。所以我真的建议 反对这一点。
使用 RowDetails
中的构建。这不会使布局与您的布局完全相同,但它是最简单、最接近您要求的内置功能。</p>
它看起来像这样:
很容易配置:设置:DataGrid XAML 中的 RowDetailsVisibilityMode="Visible"
。并为该行定义模板:
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<TextBlock Text="{Binding Desc}" Background="LightGray"/>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
[+]
所有 DataGrid 功能都可以使用:排序、添加行、调整大小...
[-]
详细信息部分跨越整行。
参见 this tutorial about what you can do with row details.
使用模板和代码隐藏。一些可能对您有帮助的资源:
关于c# - DataGrid WPF 中的 DataGridTemplateColumn 列跨度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39071767/
:) 我有一个 DataGrid。 Column2 中有“ComboBox1”,Column3 中有“ComboBox2”。只要“ComboBox1”的 SelectedIndex=0,我就想在“Co
我需要创建一个通用的DataGridTemplateColumn,以便可以在具有不同对象和属性的应用程序中使用它。 这是一些示例代码,我在我的项目中使用
嗨,我有一个 datagrid,它有许多 datagridtemplate 列,除了它们每个在模板的堆栈面板上都有不同的 datacontext 之外,这些列都是相同的。
我正在使用 WPF DataGrid来自 WPF 工具包。 我在我的 DataGrid 中添加了一个模板列,其中有 CheckBox在每个单元格中。现在如何访问这些单元格中的值? 我在 DataGri
我想将自定义控件添加到数据网格的模板列中。 自定义控件与文本框非常相似,但其中有一个图标。用户可以单击该图标,在提示窗口中选择一项,则所选项目将被填充到文本框中。 我的问题是当文本框被填充时,单击第二
如果 value in row = "No payment"我需要在数据模板中显示组合框,否则我不在行中显示组合框,我该怎么做? 这是我的数据网格模板:
我目前正在尝试使用 DataGridTemplateColumn 创建自定义控件这将在我们的许多应用程序中重复使用。我在获取自定义控件的依赖属性以正确绑定(bind)和引发属性更改通知时遇到了一些问题
BitmapImage im = new BitmapImage(); string path1 = @"C:\abc.png"; im.UriSource=new Uri(path1); DataG
为什么这样做...
我在 WPF 中有一个 DataGrid。在绑定(bind)到特定的 ItemsSource 后,我尝试将 Button 添加到网格的某些单元格。我尝试在 xaml 中执行此操作,如下所示:
我有一个可编辑的 DataGridTemplateColumn。如果业务对象满足某些条件,我只希望用户能够编辑此列中单元格的内容。假设我的业务对象实现了 INotifyPropertyChanged
我有一个可编辑的 DataGridTemplateColumn。如果业务对象满足某些条件,我只希望用户能够编辑此列中单元格的内容。假设我的业务对象实现了 INotifyPropertyChanged
如何访问 DataGridTemplateColumn 中的控件以获取值? 我正在使用此代码:
我正在创建一个窗口,供用户删除多个数据库寄存器,使用 DataGrid 显示数据,使用 Button 执行删除 所以我在 DataGrid 中放了一个 DataGridTemplateColumn ,
这是我的代码: foreach (var columnData in lookup.DataProvider.Metadata) { DataGridColumn column
我有这个 XAML,它从 ItemSource 是一个枚举的组合框中选择一个值。我使用的教程是: http://www.c-sharpcorner.com/uploadfile/dpatra/comb
请帮助解决这个问题,我不确定如何处理。 我有组合框和数据网格。每当我选择组合框值时,数据网格都应该加载新数据并且效果很好。但是当我选中所有带复选框的列时,我的 DataGridTemplateColu
我想改变DataGridTemplateColumn的内容样式,这里是DataGridTemplateColumn的代码:
我想在 DataGrid 中有自定义列: 但是,单击CheckBox(选中/取消选中)不会触发属性 setter
我是一名优秀的程序员,十分优秀!