Back to Devexpress

Gallery Class

wpf-devexpress-dot-xpf-dot-bars-6e0a2437.md

latest9.8 KB
Original Source

Gallery Class

Represents a gallery of items.

Namespace : DevExpress.Xpf.Bars

Assembly : DevExpress.Xpf.Core.v25.2.dll

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public class Gallery :
    Control
vb
Public Class Gallery
    Inherits Control

The following members return Gallery objects:

Remarks

Visually, a gallery consists of groups (GalleryItemGroup), each of which can display any number of gallery items (GalleryItem).

To add groups to a gallery, use the Gallery.Groups collection. Gallery items can be added to a group via the GalleryItemGroup.Items collection.

Example

This example demonstrates how to create a GalleryControl containing two gallery item groups.

The following image shows the result:

View Example

xaml
<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525"
    xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars">
    <Window.Resources>
        <DataTemplate x:Key="myItemDescriptionTemplate">
            <TextBlock Text="{Binding}" Foreground="Gray"></TextBlock>
        </DataTemplate>

    </Window.Resources>
    <Grid>
        <dxb:GalleryControl>
            <dxb:GalleryControl.Gallery>
                <dxb:Gallery ColCount="2" 
                     ItemCheckMode="None" 
                     IsGroupCaptionVisible="True"
                     IsItemCaptionVisible="True"
                     IsItemDescriptionVisible="True" 
                     ItemClick="Gallery_ItemClick"
                     FilterCaption="(click to filter groups)"
                     ItemDescriptionTemplate="{StaticResource ResourceKey=myItemDescriptionTemplate}"
                     ItemContentHorizontalAlignment="Left">
                    <dxb:Gallery.Groups>
                        <dxb:GalleryItemGroup Name="myGalleryGroup1" Caption="Misc Group">
                            <dxb:GalleryItemGroup.Items>
                                <dxb:GalleryItem Caption="Schedule" Description="Show schedule" Glyph="pack://application:,,,/Images/address-16x16.png"/>
                                <dxb:GalleryItem Caption="Roles" Description="Assign roles" Glyph="pack://application:,,,/Images/role-16x16.png"/>
                            </dxb:GalleryItemGroup.Items>
                        </dxb:GalleryItemGroup>
                        <dxb:GalleryItemGroup Name="myGalleryGroup2" Caption="Persons">
                            <dxb:GalleryItemGroup.Items>
                                <dxb:GalleryItem Caption="Employees" Glyph="pack://application:,,,/Images/employee-16x16.png"/>
                                <dxb:GalleryItem Caption="Persons" Glyph="pack://application:,,,/Images/person-16x16.png"/>
                                <dxb:GalleryItem Caption="Users" Glyph="pack://application:,,,/Images/user-16x16.png"/>
                            </dxb:GalleryItemGroup.Items>
                        </dxb:GalleryItemGroup>
                    </dxb:Gallery.Groups>
                </dxb:Gallery>
            </dxb:GalleryControl.Gallery>
        </dxb:GalleryControl>
    </Grid>
</Window>
csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace GalleryControl_Ex {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }

        private void Gallery_ItemClick(object sender, DevExpress.Xpf.Bars.GalleryItemEventArgs e) {
            MessageBox.Show("The " + e.Item.Caption + " item has been clicked");
        }
    }
}
vb
Class MainWindow 

    Private Sub Gallery_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.Xpf.Bars.GalleryItemEventArgs)
        MessageBox.Show("The " + e.Item.Caption + " item has been clicked")
    End Sub
End Class

The following code snippets (auto-collected from DevExpress Examples) contain references to the Gallery class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-spreadsheet-assign-custom-in-place-editors/CS/WpfSpreadsheet_CustomCellEditors/MainWindow.xaml#L520

xml
<dxr:GalleryDropDownPopupMenu.Gallery>
    <dxb:Gallery ColCount="4" ItemDescriptionHorizontalAlignment="Left" IsItemCaptionVisible="False" IsItemDescriptionVisible="False">
        <dxb:GalleryItemGroup x:Name="grpInsertChartColumn2DCommandGroup" Caption="{Binding ConverterParameter=MenuCmd_InsertChartColumn2DCommandGroup, Converter={StaticResource stringIdConverter}, Mode=OneTime, Source={StaticResource stringIdConverter}}" IsCaptionVisible="True">

wpf-spreadsheet-bind-spreadsheet-to-ms-sql-server-database/CS/WpfSpreadsheet_BindToDataSource/MainWindow.xaml#L522

xml
<dxr:GalleryDropDownPopupMenu.Gallery>
    <dxb:Gallery AllowFilter="False" ColCount="4" ItemDescriptionHorizontalAlignment="Left" IsItemCaptionVisible="False" IsItemDescriptionVisible="False" SizeMode="None">
        <dxb:GalleryItemGroup x:Name="grpInsertChartColumn2DCommandGroup" Caption="{Binding ConverterParameter=MenuCmd_InsertChartColumn2DCommandGroup, Converter={StaticResource stringIdConverter}, Mode=OneTime, Source={StaticResource stringIdConverter}}" IsCaptionVisible="True">

wpf-create-a-ribboncontrol/CS/RibbonControl_Ex/MainWindow.xaml#L211

xml
<dxr:RibbonGalleryBarItem.Gallery>
    <dxb:Gallery MinColCount="1" ColCount="5"
     ItemCheckMode="Single"

wpf-mvvm-behaviors-gallery-based-theme-selector/CS/GalleryThemeSelectorBehavior/MainWindow.xaml#L14

xml
<dxb:GalleryControl.Gallery>
    <dxb:Gallery
        ColCount="3"

create-wpf-gallery-control/CS/GalleryControl_Ex/MainWindow.xaml#L16

xml
<dxb:GalleryControl.Gallery>
    <dxb:Gallery ColCount="2"
         ItemCheckMode="None"

Inheritance

Object DispatcherObject DependencyObject Visual UIElement FrameworkElement Control Gallery

See Also

Gallery Members

RibbonGalleryBarItem

GalleryControl

DevExpress.Xpf.Bars Namespace