Class MenuItem
Represents a customizable menu item used in the SfScheduler context menu.
Inheritance
Namespace: Syncfusion.Maui.Scheduler
Assembly: Syncfusion.Maui.Scheduler.dll
Syntax
public class MenuItem : BindableObject
Constructors
MenuItem()
Initializes a new instance of the MenuItem class.
Declaration
public MenuItem()
MenuItem(String)
Initializes a new instance of the MenuItem class with the specified text.
Declaration
public MenuItem(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | The text to display for the menu item. |
MenuItem(String, FontImageSource)
Initializes a new instance of the MenuItem class with the specified text and icon.
Declaration
public MenuItem(string text, FontImageSource icon)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | The text to display for the menu item. |
| Microsoft.Maui.Controls.FontImageSource | icon | The icon to display next to the menu item text. |
MenuItem(String, ICommand)
Initializes a new instance of the MenuItem class with the specified text and command.
Declaration
public MenuItem(string text, ICommand command)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | The text to display for the menu item. |
| System.Windows.Input.ICommand | command | The command to execute when the menu item is clicked. |
MenuItem(String, ICommand, Object)
Initializes a new instance of the MenuItem class with the specified text, command, and command parameter.
Declaration
public MenuItem(string text, ICommand command, object commandParameter)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | The text to display for the menu item. |
| System.Windows.Input.ICommand | command | The command to execute when the menu item is clicked. |
| System.Object | commandParameter | The parameter to pass to the command when executed. |
Fields
CommandParameterProperty
Identifies the CommandParameter bindable property.
Declaration
public static readonly BindableProperty CommandParameterProperty
Field Value
| Type | Description |
|---|---|
| Microsoft.Maui.Controls.BindableProperty | The identifier for CommandParameter bindable property. |
CommandProperty
Identifies the Command bindable property.
Declaration
public static readonly BindableProperty CommandProperty
Field Value
| Type | Description |
|---|---|
| Microsoft.Maui.Controls.BindableProperty | The identifier for Command bindable property. |
Properties
Command
Gets or sets the command that is executed when the menu item is selected.
Declaration
public ICommand Command { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Windows.Input.ICommand | An System.Windows.Input.ICommand implementation to execute. The default value is |
Remarks
The command is executed only if its CanExecute method returns true. The value of the CommandParameter property is passed as the SchedulerContextMenuInfo instance during execution.
Examples
The below examples shows, how to use the Command property of MenuItem in the SfScheduler.
<schedule:MenuItem Text="Add"
Command="{Binding AddAppointmentCommand}"
CommandParameter="{Binding}" />
CommandParameter
Gets or sets the parameter passed to the command when it is executed.
Declaration
public object CommandParameter { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Object | An object that is supplied as the command parameter. The default value is |
Remarks
This parameter is passed to both the Execute and CanExecute methods of the associated command. In scheduler context menus, this is
typically a SchedulerContextMenuInfo instance that provides details about the selected date, appointment, and resource.
Examples
The below examples shows, how to use the CommandParameter property of MenuItem in the SfScheduler.
<schedule:MenuItem Text="Add"
Command="{Binding AddAppointmentCommand}"
CommandParameter="{Binding}" />
Icon
Gets or sets the icon displayed alongside the menu item text.
Declaration
public FontImageSource Icon { get; set; }
Property Value
| Type | Description |
|---|---|
| Microsoft.Maui.Controls.FontImageSource | The default value is |
Remarks
Icons provide a visual indicator of the menu item's action. If no icon is specified, only the text is displayed.
Examples
The below examples shows, how to use the Icon property of MenuItem in the SfScheduler.
<schedule:MenuItem Text="Delete">
<schedule:MenuItem.Icon>
<Image Source="delete_icon.png" WidthRequest="16" HeightRequest="16" />
</schedule:MenuItem.Icon>
</schedule:MenuItem>
IconSize
Gets or sets the size of the icon for the menu item.
Declaration
public int IconSize { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | The default value is |
Remarks
Icons provide a visual indicator of the menu item's action. If no icon is specified, only the text is displayed.
Examples
The below examples shows, how to use the IconSize property of MenuItem in the SfScheduler.
<schedule:MenuItem Text="Delete" IconSize="12" >
<schedule:MenuItem.Icon>
<Image Source="delete_icon.png" WidthRequest="16" HeightRequest="16" />
</schedule:MenuItem.Icon>
</schedule:MenuItem>
Text
Gets or sets the text displayed for the menu item.
Declaration
public string Text { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String | A string that represents the menu item label. The default value is an empty string. |
Remarks
The text should clearly describe the action performed when the menu item is selected.
Examples
The below examples shows, how to use the Text property of MenuItem in the SfScheduler.