menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class MenuItemCollection - MAUI API Reference | Syncfusion

    Show / Hide Table of Contents

    Class MenuItemCollection

    Represents a collection of context menu items used in SfDataGrid.

    Inheritance
    System.Object
    MenuItemCollection
    Namespace: Syncfusion.Maui.DataGrid
    Assembly: Syncfusion.Maui.DataGrid.dll
    Syntax
    public class MenuItemCollection : ObservableCollection<MenuItem>
    Remarks

    This class supports declarative definition of context menu items, typically used in grid-level menus such as header, record, or summary. It is commonly defined in XAML using the SfDataGrid context menu properties.

    Examples

    Here is an example of how to use the MenuItemCollection in the HeaderContextMenu property.

    [XAML]

    <syncfusion:SfDataGrid x:Name="dataGrid"
                            ItemsSource="{Binding YourData}"
                            AutoGenerateColumns="True">
        <syncfusion:SfDataGrid.HeaderContextMenu>
            <syncfusion:MenuItemCollection>
                <syncfusion:MenuItem Text="Sort Ascending" Command="{Binding SortAscendingCommand}" />
                <syncfusion:MenuItem Text="Sort Descending" Command="{Binding SortDescendingCommand}" />
            </syncfusion:MenuItemCollection>
        </syncfusion:SfDataGrid.HeaderContextMenu>
    </syncfusion:SfDataGrid>

    [C#]

    dataGrid.HeaderContextMenu = new MenuItemCollection
    {
        new MenuItem { Text = "Sort Ascending", Command = ViewModel.SortAscendingCommand },
        new MenuItem { Text = "Sort Descending", Command = ViewModel.SortDescendingCommand }
    };

    Constructors

    MenuItemCollection()

    Initializes a new instance of the MenuItemCollection class.

    Declaration
    public MenuItemCollection()

    Properties

    Items

    Gets the collection of menu items.

    Declaration
    public ObservableCollection<MenuItem> Items { get; }
    Property Value
    Type
    System.Collections.ObjectModel.ObservableCollection<MenuItem>
    Remarks

    This property is the content property for XAML, allowing direct declaration of menu items. It returns the collection itself.

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved