question

PaulaMorgan-3461 avatar image
PaulaMorgan-3461 asked ·

[UWP][C#] Datagrid with button column

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

windows-uwp
1 comment
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

hi paula kindly let me know how you get the solution i am facing the same problem with ComboBox and Button.

i am using dataTable for making dynamic columns then assign the dataTable to dataGrid. kindly help me in this manner.

0 Votes 0 · ·

1 Answer

FayWang-MSFT avatar image
FayWang-MSFT answered ·

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.


3 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for replying @FayWang-MSFT. The link goes to a 404/page not found page.

0 Votes 0 · ·

Sorry, please refer to here.


0 Votes 0 · ·

@FayWang-MSFT - Thank you...exactly what I needed!

0 Votes 0 · ·