SHRI
SHRI

Reputation: 2466

Add button in grid

I am new to WPF. I have a code which displays a UI window and it has a table. The contents are empty. Only Column names are present.

During execution, after performing some operation, the row is added. Elements in row are displayed. Progress bar is also an element of row. Now I want to add one button as an element in that row. But I cannot see the row in designer.

I have no idea how to do that. I searched allot in forums and books but I did not get it. How to start? Please help. Thanks.

Upvotes: 0

Views: 136

Answers (1)

Bas
Bas

Reputation: 27095

You can use a DataGridTemplateColumn:

<DataGrid>
    <DataGrid.Columns>
        <DataGridTemplateColumn>
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Button>Click Me!</Button>
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
    </DataGrid.Columns>
</DataGrid>

Upvotes: 1

Related Questions