[UWP][C#] Datagrid with button column

Paula Morgan 276 Reputation points
2020-02-04T19:22:05.343+00:00

Hi,

I need to add a button column to my grid using C# - not XAML. I am able to add a checkbox and a combobox by creating an instance of DataGridCheckBoxColumn and DataGridComboBoxColumn.

What do I use for a button column? I'm guessing DataGridTemplateColumn, but I cannot find any useful examples about how to create it in code behind instead of xaml.

Thanks for any help!
Paula

Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Fay Wang - MSFT 5,221 Reputation points
    2020-02-05T06:26:20.087+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    If you want to customize columns, you can use DataGridTemplateColumn. The DataGridTemplateColumn type enables you to create your own column types by specifying the cell templates used to display values. If you want to achieve it in code-behind, you need to create a dataTemplate contain button and apply it in the CellTemplate of DataGridTemplateColumn.

    You can see more details from here.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.