In This Article

BarMenuGallery Class

Represents a gallery control, for use within a menu.

[TemplatePart("PART_FilterButton", typeof(BarMenuGalleryFilterButton))]
[TemplatePart("PART_ResizablePanel", typeof(BarMenuGalleryResizablePanel))]
[PseudoClasses(new string[] { ":no-padding" })]
public class BarMenuGallery : BarGalleryBase, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue, IChildIndexProvider, ICommandSource, IDragResizableControl
Inheritance:
object AvaloniaObject Animatable StyledElement Visual Layoutable Interactive InputElement Control TemplatedControl ItemsControl SelectingItemsControl BarGalleryBase object
Derived:
BarSizeSelectionMenuGallery
Implements:
IDataContextProvider ILogical IThemeVariantHost IResourceHost IResourceNode IStyleHost ISetLogicalParent ISetInheritanceParent IStyleable INamed IInputElement IDataTemplateHost ISetterValue IChildIndexProvider ICommandSource IDragResizableControl

Constructors

BarMenuGallery()

Initializes an instance of the class.

public BarMenuGallery()

Properties

AreSurroundingSeparatorsAllowed

Whether the menu gallery can render surrounding separators.

public bool AreSurroundingSeparatorsAllowed { get; set; }

Property Value

bool:

The default value is true.

CanCategorize

Whether the gallery sorts and displays items by category when an ICollectionView is set to the ItemsSource.

public bool CanCategorize { get; set; }

Property Value

bool:

The default value is true.

CanFilter

Whether the gallery supports filtering of items by category.

public bool CanFilter { get; set; }

Property Value

bool:

The default value is false.

CategoryContainerTheme

The Avalonia.Styling.ControlTheme used for the container of categorized items.

public ControlTheme? CategoryContainerTheme { get; set; }

Property Value

ControlTheme

CategoryHeaderTemplate

The Avalonia.Controls.Templates.IDataTemplate used for the header of a category.

public IDataTemplate? CategoryHeaderTemplate { get; set; }

Property Value

IDataTemplate

DefaultCategoryHeaderTemplate

The default Avalonia.Controls.Templates.IDataTemplate used for the header of a category.

public IDataTemplate? DefaultCategoryHeaderTemplate { get; set; }

Property Value

IDataTemplate

HasCategoryHeaders

Whether the gallery has category headers when categorizing.

public bool HasCategoryHeaders { get; set; }

Property Value

bool:

The default value is true.

IsFilterButtonVisible

Whether the filter button is visible.

public bool IsFilterButtonVisible { get; }

Property Value

bool

ItemTemplateSelector

The IDataTemplateSelector that selects a content template based on a data item and container control

public IDataTemplateSelector? ItemTemplateSelector { get; set; }

Property Value

IDataTemplateSelector

MaxColumnCount

The maximum number of columns.

public int MaxColumnCount { get; set; }

Property Value

int:

The default value is MaxValue.

MinColumnCount

The minimum number of columns.

public int MinColumnCount { get; set; }

Property Value

int:

The default value is 1.

ResizeMode

A ControlResizeMode that indicates how the menu that contains the gallery can resize.

public ControlResizeMode ResizeMode { get; set; }

Property Value

ControlResizeMode:

The default value is None.

SelectFilterCategoryCommand

Provides an ICommand used to select the filter category specified in the command parameter.

public ICommand? SelectFilterCategoryCommand { get; }

Property Value

ICommand

SelectedFilterCategory

The selected filter category name.

public string? SelectedFilterCategory { get; set; }

Property Value

string:

The selected filter category name.

UseMenuItemAppearance

Whether to use a menu item appearance for gallery items, common for single-column menu galleries.

public bool UseMenuItemAppearance { get; set; }

Property Value

bool:

The default value is false.

UseMenuItemIndent

Whether to align gallery items in a menu so that they indent past the menu's icon column.

public bool UseMenuItemIndent { get; set; }

Property Value

bool:

The default value is false.

Methods

CreateContainerForItemOverride(object?, int, object?)

Creates or a container that can be used to display an item.

protected override Control CreateContainerForItemOverride(object? item, int index, object? recycleKey)
Parameter Type Description
item object
index int
recycleKey object

Returns

Control

OnApplyTemplate(TemplateAppliedEventArgs)

Called when the control's template is applied. In simple terms, this means the method is called just before the control is displayed.

protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
Parameter Type Description
e TemplateAppliedEventArgs

The event args.

OnCreateAutomationPeer()

Returns a new, type-specific Avalonia.Automation.Peers.AutomationPeer implementation for the control.

protected override AutomationPeer OnCreateAutomationPeer()

Returns

AutomationPeer:

The type-specific Avalonia.Automation.Peers.AutomationPeer implementation.

OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)

Called when the control is removed from a rooted visual tree.

protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
Parameter Type Description
e VisualTreeAttachmentEventArgs

The event args.

PrepareContainerForItemOverride(Control, object?, int)

Prepares the specified element to display the specified item.

protected override void PrepareContainerForItemOverride(Control container, object? item, int index)
Parameter Type Description
container Control

The element that's used to display the specified item.

item object

The item to display.

index int

The index of the item to display.

Render(DrawingContext)

Renders the visual to a Avalonia.Media.DrawingContext.

public override void Render(DrawingContext context)
Parameter Type Description
context DrawingContext

The drawing context.

Fields

AreSurroundingSeparatorsAllowedProperty

Defines the AreSurroundingSeparatorsAllowed property.

public static readonly StyledProperty<bool> AreSurroundingSeparatorsAllowedProperty

CanCategorizeProperty

Defines the CanCategorize property.

public static readonly StyledProperty<bool> CanCategorizeProperty

CanFilterProperty

Defines the CanFilter property.

public static readonly StyledProperty<bool> CanFilterProperty

CategoryContainerThemeProperty

Defines the CategoryContainerTheme property.

public static readonly StyledProperty<ControlTheme?> CategoryContainerThemeProperty

CategoryHeaderTemplateProperty

Defines the CategoryHeaderTemplate property.

public static readonly StyledProperty<IDataTemplate?> CategoryHeaderTemplateProperty

DefaultCategoryHeaderTemplateProperty

Defines the DefaultCategoryHeaderTemplate property.

public static readonly StyledProperty<IDataTemplate?> DefaultCategoryHeaderTemplateProperty

HasCategoryHeadersProperty

Defines the HasCategoryHeaders property.

public static readonly StyledProperty<bool> HasCategoryHeadersProperty

IsFilterButtonVisibleProperty

Defines the IsFilterButtonVisible property.

public static readonly DirectProperty<BarMenuGallery, bool> IsFilterButtonVisibleProperty

ItemTemplateSelectorProperty

Defines the ItemTemplateSelector property.

public static readonly StyledProperty<IDataTemplateSelector?> ItemTemplateSelectorProperty

MaxColumnCountProperty

Defines the MaxColumnCount property.

public static readonly StyledProperty<int> MaxColumnCountProperty

MinColumnCountProperty

Defines the MinColumnCount property.

public static readonly StyledProperty<int> MinColumnCountProperty

ResizeModeProperty

Defines the ResizeMode property.

public static readonly StyledProperty<ControlResizeMode> ResizeModeProperty

SelectedFilterCategoryProperty

Defines the SelectedFilterCategory property.

public static readonly StyledProperty<string?> SelectedFilterCategoryProperty

UseMenuItemAppearanceProperty

Defines the UseMenuItemAppearance property.

public static readonly StyledProperty<bool> UseMenuItemAppearanceProperty

UseMenuItemIndentProperty

Defines the UseMenuItemIndent property.

public static readonly StyledProperty<bool> UseMenuItemIndentProperty

Inherited Members

Extension Methods