StillWorking28269
StillWorking28269

Reputation: 2321

How to add context menu to wpf datagrid?

How does one add a ContextMenu to a DataGrid? I want to be able to right click anywhere on the DataGrid.

Upvotes: 65

Views: 68531

Answers (1)

StillWorking28269
StillWorking28269

Reputation: 2321

<DataGrid>
    <DataGrid.ContextMenu>
        <ContextMenu>
            <MenuItem Header="Click Me" Click="MenuItem_Click" />
        </ContextMenu>
    </DataGrid.ContextMenu>
</DataGrid>

Upvotes: 167

Related Questions