In This Article

BarGalleryBase Class

Represents an abstract base class for a gallery control.

public abstract class BarGalleryBase : Selector
Inheritance:
object Visual UIElement FrameworkElement Control ItemsControl Selector object
Derived:
BarMenuGallery BarMenuGalleryHostBase

Constructors

BarGalleryBase()

Initializes an instance of the class.

protected BarGalleryBase()

Properties

BetweenPreviewDelay

The delay in milliseconds between PreviewedItem updates as a new item is highlighted.

public int BetweenPreviewDelay { get; set; }

Property Value

int:

The default value is 0.

CanCloneToRibbonQuickAccessToolBar

Indicates whether the control can be cloned to the ribbon quick-access toolbar.

public bool CanCloneToRibbonQuickAccessToolBar { get; set; }

Property Value

bool:

true if the control can be cloned to the ribbon quick-access toolbar; otherwise, false. The default value is true.

CanStopPreviewingOnMouseLeave

Indicates whether the gallery can stop previewing when the mouse leaves the control.

protected virtual bool CanStopPreviewingOnMouseLeave { get; }

Property Value

bool:

true if the gallery can stop previewing when the mouse leaves the control; otherwise, false.

Command

The ICommand to execute when a gallery item is selected.

public ICommand? Command { get; set; }

Property Value

ICommand

CommandTarget

The IInputElement target for the Command.

public IInputElement? CommandTarget { get; set; }

Property Value

IInputElement

HighlightedItem

The item that is currently highlighted.

public object? HighlightedItem { get; }

Property Value

object

InitialPreviewDelay

The delay in milliseconds for preview mode to begin after an item is highlighted.

public int InitialPreviewDelay { get; set; }

Property Value

int:

The default value is 300.

IsSelectionSupported

Indicates whether selection is supported.

public bool IsSelectionSupported { get; set; }

Property Value

bool:

true if selection is supported; otherwise, false. The default value is true.

ItemSpacing

The amount of spacing between items.

public double ItemSpacing { get; set; }

Property Value

double:

The default value is 0.

Key

A string that uniquely identifies the control.

[Localizability(LocalizationCategory.NeverLocalize)]
public string Key { get; set; }

Property Value

string

Label

The text label to display.

[Localizability(LocalizationCategory.Label)]
public string Label { get; set; }

Property Value

string

LargeImageSource

The ImageSource for a large image, generally 32x32 size.

public ImageSource? LargeImageSource { get; set; }

Property Value

ImageSource

MediumImageSource

The ImageSource for a medium image, generally 24x24 size.

public ImageSource? MediumImageSource { get; set; }

Property Value

ImageSource

MinItemHeight

The minimum item height.

public double MinItemHeight { get; set; }

Property Value

double:

The default value is 16.0.

MinItemWidth

The minimum item width.

public double MinItemWidth { get; set; }

Property Value

double:

The default value is 16.0.

PreviewedItem

The item that is currently being previewed.

public object? PreviewedItem { get; }

Property Value

object

SmallImageSource

The ImageSource for a small image, generally 16x16 size.

public ImageSource? SmallImageSource { get; set; }

Property Value

ImageSource

StaysOpenOnClick

Indicates whether the gallery doesn't try to restore focus to the main focus scope when an item is clicked.

public bool StaysOpenOnClick { get; set; }

Property Value

bool:

true if the gallery doesn't try to restore focus to the main focus scope when an item is clicked; otherwise, false. The default value is false.

Title

The string title, which can override the Label when displayed in screen tips and customization UI.

[Localizability(LocalizationCategory.Title)]
public string? Title { get; set; }

Property Value

string:

The string title.

UseAccentedItemBorder

Indicates whether to use an accented item border for gallery items, common when they have vibrant content such as color swatches.

public bool UseAccentedItemBorder { get; set; }

Property Value

bool:

true if an accented item border should be used for gallery items; otherwise, false. The default value is false.

UserInterfaceDensity

A UserInterfaceDensity that indicates how compact or spacious the UI should appear.

public UserInterfaceDensity UserInterfaceDensity { get; set; }

Property Value

UserInterfaceDensity:

The default value is Compact.

Methods

ClearContainerForItemOverride(DependencyObject, object)

Returns an item container to the state it was in before PrepareContainerForItemOverride(DependencyObject, object).

protected override void ClearContainerForItemOverride(DependencyObject element, object item)
Parameter Type Description
element DependencyObject

The item container element.

item object

The data item.

GetContainerForItemOverride()

Creates or identifies the element that is used to display the given item.

protected override DependencyObject GetContainerForItemOverride()

Returns

DependencyObject:

The element that is used to display the given item.

IsItemItsOwnContainerOverride(object)

Determines if the specified item is (or is eligible to be) its own container.

protected override bool IsItemItsOwnContainerOverride(object item)
Parameter Type Description
item object

The item to check.

Returns

bool:

true if the item is (or is eligible to be) its own container; otherwise, false.

OnHighlightedItemChanged(RoutedEventArgs)

Occurs after the HighlightedItem property has changed.

protected virtual void OnHighlightedItemChanged(RoutedEventArgs e)
Parameter Type Description
e RoutedEventArgs

The event data.

OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs)

Called when the IsKeyboardFocusWithin property has changed.

protected override void OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs e)
Parameter Type Description
e DependencyPropertyChangedEventArgs

The event data.

OnItemSpacingPropertyValueChanged(DependencyPropertyChangedEventArgs)

Occurs when the ItemSpacing property value changes.

protected virtual void OnItemSpacingPropertyValueChanged(DependencyPropertyChangedEventArgs e)
Parameter Type Description
e DependencyPropertyChangedEventArgs

The event data.

OnMinItemHeightPropertyValueChanged(DependencyPropertyChangedEventArgs)

Occurs when the MinItemHeight property value changes.

protected virtual void OnMinItemHeightPropertyValueChanged(DependencyPropertyChangedEventArgs e)
Parameter Type Description
e DependencyPropertyChangedEventArgs

The event data.

OnMinItemWidthPropertyValueChanged(DependencyPropertyChangedEventArgs)

Occurs when the MinItemWidth property value changes.

protected virtual void OnMinItemWidthPropertyValueChanged(DependencyPropertyChangedEventArgs e)
Parameter Type Description
e DependencyPropertyChangedEventArgs

The event data.

OnMouseLeave(MouseEventArgs)

Invoked when an unhandled System.Windows.Input.Mouse.MouseLeave attached event is raised on this element. Implement this method to add class handling for this event.

protected override void OnMouseLeave(MouseEventArgs e)
Parameter Type Description
e MouseEventArgs

The MouseEventArgs that contains the event data.

OnMouseMove(MouseEventArgs)

Invoked when an unhandled System.Windows.Input.Mouse.MouseMove attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

protected override void OnMouseMove(MouseEventArgs e)
Parameter Type Description
e MouseEventArgs

The MouseEventArgs that contains the event data.

OnSelectionChanged(SelectionChangedEventArgs)

Called when the selection changes.

protected override void OnSelectionChanged(SelectionChangedEventArgs e)
Parameter Type Description
e SelectionChangedEventArgs

The event data.

OnUserInterfaceDensityPropertyValueChanged(DependencyPropertyChangedEventArgs)

Occurs when the UserInterfaceDensity property value changes.

protected virtual void OnUserInterfaceDensityPropertyValueChanged(DependencyPropertyChangedEventArgs e)
Parameter Type Description
e DependencyPropertyChangedEventArgs

The event data.

PrepareContainerForItemOverride(DependencyObject, object)

Prepares the specified element to display the specified item.

protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
Parameter Type Description
element DependencyObject

The element that is used to display the specified item.

item object

The specified item to display.

ScrollToSelectedItem(bool)

Scrolls the gallery to the selected item.

public void ScrollToSelectedItem(bool canFocus)
Parameter Type Description
canFocus bool

Whether to also focus the selected gallery item.

ToString()

Returns the string representation of this object.

public override string ToString()

Returns

string:

The string representation of this object.

Events

HighlightedItemChanged

Occurs after the HighlightedItem property has changed.

public event RoutedEventHandler HighlightedItemChanged

Event Type

RoutedEventHandler

Fields

BetweenPreviewDelayProperty

Defines the BetweenPreviewDelay property.

public static readonly DependencyProperty BetweenPreviewDelayProperty

CanCloneToRibbonQuickAccessToolBarProperty

Defines the CanCloneToRibbonQuickAccessToolBar property.

public static readonly DependencyProperty CanCloneToRibbonQuickAccessToolBarProperty

CommandProperty

Defines the Command property.

public static readonly DependencyProperty CommandProperty

CommandTargetProperty

Defines the CommandTarget property.

public static readonly DependencyProperty CommandTargetProperty

HighlightedItemChangedEvent

Defines the HighlightedItemChanged routed event.

public static readonly RoutedEvent HighlightedItemChangedEvent

HighlightedItemProperty

Defines the HighlightedItem property.

public static readonly DependencyProperty HighlightedItemProperty

InitialPreviewDelayProperty

Defines the InitialPreviewDelay property.

public static readonly DependencyProperty InitialPreviewDelayProperty

IsSelectionSupportedProperty

Defines the IsSelectionSupported property.

public static readonly DependencyProperty IsSelectionSupportedProperty

ItemSpacingProperty

Defines the ItemSpacing property.

public static readonly DependencyProperty ItemSpacingProperty

KeyProperty

Defines the Key property.

public static readonly DependencyProperty KeyProperty

LabelProperty

Defines the Label property.

public static readonly DependencyProperty LabelProperty

LargeImageSourceProperty

Defines the LargeImageSource property.

public static readonly DependencyProperty LargeImageSourceProperty

MediumImageSourceProperty

Defines the MediumImageSource property.

public static readonly DependencyProperty MediumImageSourceProperty

MinItemHeightProperty

Defines the MinItemHeight property.

public static readonly DependencyProperty MinItemHeightProperty

MinItemWidthProperty

Defines the MinItemWidth property.

public static readonly DependencyProperty MinItemWidthProperty

PreviewedItemProperty

Defines the PreviewedItem property.

public static readonly DependencyProperty PreviewedItemProperty

SmallImageSourceProperty

Defines the SmallImageSource property.

public static readonly DependencyProperty SmallImageSourceProperty

StaysOpenOnClickProperty

Defines the StaysOpenOnClick property.

public static readonly DependencyProperty StaysOpenOnClickProperty

TitleProperty

Defines the Title property.

public static readonly DependencyProperty TitleProperty

UseAccentedItemBorderProperty

Defines the UseAccentedItemBorder property.

public static readonly DependencyProperty UseAccentedItemBorderProperty

UserInterfaceDensityProperty

Defines the UserInterfaceDensity property.

public static readonly DependencyProperty UserInterfaceDensityProperty

Extension Methods