Click here to Skip to main content
13,003,102 members (60,305 online)
Click here to Skip to main content
Add your own
alternative version


Posted 5 Dec 2011

Hide DevExpress AgDataGrid Header MenuItem in Silverlight

, 25 Dec 2011
Rate this:
Please Sign up or sign in to vote.


DevExpress AgDatagrid has some good features like grouping column, filter column, columnchooser, etc.

Sometimes, we need to hide some of the menu items of AgDataGrid header.

Let's start how to hide AgDataGrid coloumn header menu item.

Step 1: Drag and Drop DataGrid into XAML page from DevExpress ToolBox.

<Grid x:Name="LayoutRoot">
         <dxg:AgDataGrid    FocusMode="Row">

Step 2: Add Column into grid and create event for HeaderMenuShowing

     <dxg:AgDataGridColumn  AllowEditing="False"
         HeaderContent="Signal Time"
         HeaderMenuShowing="AgDataGridColumn_HeaderMenuShowing" />

You have to create event handler for each datagrid column for which you don't want menu items.

Step 3: In code behind (C#), write code to hide unwanted header menu items.

private void AgDataGridColumn_HeaderMenuShowing(object sender, ShowContextMenuEventArgs e)
            int cnt = 0;
            var v = e.Menu.Items as ItemCollection;
            foreach (var d in v)
                if (d.GetType() == typeof(AgMenuItem))
                    AgMenuItem myItem = d as AgMenuItem;
                    if (myItem.Header.ToString() == "Show Group Box" || 
myItem.Header.ToString() == "Remove This Column" || myItem.Header.ToString() == "Show Column Chooser")
                        myItem.Visibility = Visibility.Collapsed;
                        if (myItem.Header.ToString() == "Show Column Chooser")
                            cnt = 1;
                if (d.GetType() == typeof(AgMenuSeparator) && cnt == 1)
                    (d as AgMenuSeparator).Visibility = Visibility.Collapsed;
                    cnt = 0;


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Hiren Khirsaria
Software Developer (Senior)
India India
has Total 7+ years of Experience in Microsoft.Net Environment.

Major Development Skills are : WPF, Silverlight, Windows Mobile, WCF RIA Service, C#, Sql Server & ASP.Net

Follow him on :

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170626.1 | Last Updated 25 Dec 2011
Article Copyright 2011 by Hiren Khirsaria
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid