Articles in this section
Category / Section

How to bind the ItemSource for ContextMenu of SfdataGrid

1 min read

SfDataGrid allows you to set the ContextMenus for Headers, Records, GroupCaption, GroupDropArea, GroupDropItem, GroupSummary, and TableSummary. Menu collections are bounded as ItemSource for ContextMenu with the ItemSource property binding. Refer the following code sample,

 XAML

<Window.Resources>
    <local:ViewModel x:Key="ViewModel" />
</Window.Resources>
<Syncfusion:SfDataGrid.HeaderContextMenu>
    <ContextMenu ItemsSource="{Binding MenuList, Source={StaticResource ViewModel}}" />
</Syncfusion:SfDataGrid.HeaderContextMenu>

 

Here, MenuList property can be accessed from ViewModel by setting StaticResource. ContextMenu for Header is set using SfDataGrid.HeaderContextMenu. Similarly ContextMenu can be set for Records, GroupCaption, GroupDropArea, GroupDropItem, GroupSummary, and TableSummary.

The following screenshot shows the ContextMenu of Header,

 

F:\KB\HeaderContextMenu.png

 

 

You can refer to the sample from the following location.

Sample Link: WPF

 

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please sign in to leave a comment
Access denied
Access denied