【问题标题】:WPF DataGrid row templateWPF DataGrid 行模板
【发布时间】:2017-06-05 11:48:21
【问题描述】:

我是 WPF 的新手,遇到了一个问题:
我需要在 DataGrid 中设置行模板。它应该如下图所示。

也许有人知道怎么做?

提前感谢您!

【问题讨论】:

  • 图像的哪一部分特别难以重建?这里有大量关于该主题的在线文档和回答问题。
  • 到目前为止你尝试了什么?你能展示你的代码吗?
  • 查看How to Ask,了解如何提出好问题的详细信息。

标签: c# .net wpf wpfdatagrid


【解决方案1】:

要自定义 DataGrid,请使用 DataGridTemplate 列。在下面的示例中,CustomizedUIElement 是具有您想要的布局的其他控件。

<DataGridTemplateColumn Header="ColumnHeader">
     <DataGridTemplateColumn.CellTemplate>
           <DataTemplate>
                 <local:CustomizedUIElement Text="{Binding Path=PropertyToBindTo}"/>
           </DataTemplate>
     </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

使用您想要的布局创建一个用户控件,然后将其注入到数据网格中,如上所示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-14
    • 2017-10-30
    • 1970-01-01
    • 2022-09-27
    • 2020-11-26
    • 2011-03-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多