In This Article

MenuFactory<TMenu, TMenuItem, TSeparator> Class

An implementation of IMenuFactory for creating default menu controls supported by the platform.

public class MenuFactory<TMenu, TMenuItem, TSeparator> : IMenuFactory where TMenu : MenuFlyout, new() where TMenuItem : MenuItem, new() where TSeparator : Separator, new()
Type Parameters:
TMenu -
TMenuItem -
TSeparator -
Inheritance:
object object
Derived:
BarsMenuFactory
Implements:
IMenuFactory

Constructors

MenuFactory()

Initializes an instance of the class.

public MenuFactory()

Properties

AllowIcons

Indicates if menu items are allowed to show icons, when available.

public bool AllowIcons { get; set; }

Property Value

bool:

true to allow icons, when available; otherwise, false to hide icons. The default value is true.

See Also

AllowInputGestures

Indicates if menu items are allowed to show input gestures (e.g., keyboard shortcuts), when available.

public bool AllowInputGestures { get; set; }

Property Value

bool:

true to allow input gestures, when available; otherwise, false to hide input gestures. The default value is true.

See Also

CanResolveIconsThroughImageProvider

Indicates if icons can be resolved through ImageProvider when an explicit icon is not provided for a menu item. When true, the Key will used as the key passed to GetImageSource(string).

public bool CanResolveIconsThroughImageProvider { get; set; }

Property Value

bool

See Also

ImageProvider

Optionally defines an explicit provider that can be used to resolve images. When null, Default will be used.

public ImageProvider? ImageProvider { get; set; }

Property Value

ImageProvider

See Also

Methods

CoerceMenuItemOptionsFromCommand(MenuFactoryMenuItemOptions, ICommand)

Coerces unset options from a command.

protected virtual void CoerceMenuItemOptionsFromCommand(MenuFactoryMenuItemOptions options, ICommand command)
Parameter Type Description
options MenuFactoryMenuItemOptions

The options to be updated.

command ICommand

The command to examine.

CreateIconControl(object?, IDataTemplate?)

Creates the control used to display an icon.

protected virtual Control? CreateIconControl(object? icon, IDataTemplate? iconTemplate)
Parameter Type Description
icon object

The value which defines the icon.

iconTemplate IDataTemplate

The data template for the icon.

Returns

Control:

The icon control, or null if a control was not created.

CreateMenu(MenuFactoryMenuOptions?)

Creates a menu.

public TMenu CreateMenu(MenuFactoryMenuOptions? options)
Parameter Type Description
options MenuFactoryMenuOptions

The options for the new menu. When null, default options will be used.

Returns

TMenu

CreateMenuCore(MenuFactoryMenuOptions)

Creates and configures a new instance of a menu.

protected virtual TMenu CreateMenuCore(MenuFactoryMenuOptions options)
Parameter Type Description
options MenuFactoryMenuOptions

The options for the new menu.

Returns

TMenu

CreateMenuItem(MenuFactoryMenuItemOptions?)

Creates a menu item.

public TMenuItem CreateMenuItem(MenuFactoryMenuItemOptions? options)
Parameter Type Description
options MenuFactoryMenuItemOptions

The options for the new menu item. When null, default options will be used.

Returns

TMenuItem

CreateMenuItemCore(MenuFactoryMenuItemOptions)

Creates and configures a new instance of a menu item.

protected virtual TMenuItem CreateMenuItemCore(MenuFactoryMenuItemOptions options)
Parameter Type Description
options MenuFactoryMenuItemOptions

The options for the new menu item.

Returns

TMenuItem

CreateMenuSeparator()

Creates a separator.

public TSeparator CreateMenuSeparator()

Returns

TSeparator

CreateMenuSeparatorCore()

Creates and configures a new instance of a menu separator.

protected virtual TSeparator CreateMenuSeparatorCore()

Returns

TSeparator

ResolveHeaderText(string?, bool)

Resolves the header text (i.e., label) for a menu item.

protected virtual string? ResolveHeaderText(string? text, bool allowAccessKey = true)
Parameter Type Description
text string

The desired header text.

allowAccessKey bool

true to allow access characters; otherwise false to escape access characters.

Returns

string

ResolveIcon(MenuFactoryMenuItemOptions)

Resolves the icon to be used for a menu item.

protected virtual object? ResolveIcon(MenuFactoryMenuItemOptions options)
Parameter Type Description
options MenuFactoryMenuItemOptions

Returns

object

ResolveMenuOverlayDismissEventPassThrough(bool?, object?)

Resolves the value to be used for overlay overlay dismiss event pass-through.

protected virtual bool? ResolveMenuOverlayDismissEventPassThrough(bool? explicitOption, object? owner)
Parameter Type Description
explicitOption bool?

The explicit value, if any, provided through options.

owner object

The owner, of any, associated with the menu.

Returns

bool?

ToString()

Returns the string representation of this object.

public override string ToString()

Returns

string:

The string representation of this object.

Inherited Members

Extension Methods