Back to Devexpress

BarItem.Glyph Property

wpf-devexpress-dot-xpf-dot-bars-dot-baritem-ecdc1a85.md

latest11.7 KB
Original Source

BarItem.Glyph Property

Gets or sets the item’s small image. This is a dependency property.

Namespace : DevExpress.Xpf.Bars

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

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public ImageSource Glyph { get; set; }
vb
Public Property Glyph As ImageSource

Property Value

TypeDescription
ImageSource

An ImageSource object that specifies the item’s small image.

|

Remarks

You can assign glyphs to bar items with the following properties:

PropertyGlyph size
BarItem.Glyph16*16
BarItem.LargeGlyph32*32
BarItem.MediumGlyph20*20

If both large and small images are assigned, the bar item’s links displays an image that matches the settings provided by bar objects (a bar item, bar, menu, and bar manager). For example, if a bar item link is displayed within a toolbar, the large image is displayed. If a bar item link is displayed within sub-menus, small images are used. The BarItem.MediumGlyph is used in the Ribbon’s Simplified Mode.

Use the BarManager.ToolbarGlyphSize and BarManager.MenuGlyphSize properties to specify the size of images for bar item links displayed in bars and menus, respectively. You can override this setting for individual bars, popup menus, submenus, and link containers via the Bar.GlyphSize, PopupMenu.GlyphSize, BarSubItem.SubItemsGlyphSize and BarLinkContainerItem.SubItemsGlyphSize properties, respectively. It’s possible to override this setting for individual bar items via the BarItem.GlyphSize property.

If the GlyphSize setting is set to Small (or Large ), but a small (or large, accordingly) image is not assigned to the Glyph (or LargeGlyph )property, no image is displayed.

Control images can be automatically substituted for other images based on the app context (the system DPI setting, the application UI culture, paint theme and touch mode availability). See the following topic to learn more: Automatically Choosing Images Based on App Context.

Example

This example shows how to create bar items and associate them with a custom Format category.

The following image shows the result:

vb
Imports System
Imports System.Collections.Generic
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Windows

Namespace WpfApplication3
    ''' <summary>
    ''' Interaction logic for App.xaml
    ''' </summary>
    Partial Public Class App
        Inherits Application

        Private Sub OnAppStartup_UpdateThemeName(ByVal sender As Object, ByVal e As StartupEventArgs)

            DevExpress.Xpf.Core.ApplicationThemeHelper.UpdateApplicationThemeName()
        End Sub
    End Class
End Namespace
xaml
<Window x:Class="WpfApplication3.Window1" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" 
        xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
        Title="Window1" Height="300" Width="300" >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <dxb:BarContainerControl Grid.Row="0">
            <dxb:ToolBarControl Caption="Main Toolbar">
                <dxb:BarCheckItem Content="Bold" Glyph="{dx:DXImage Image=Bold_16x16.png}" CategoryName="Format" 
                                  CheckedChanged="checkBtnBold_CheckChanged"/>
                <dxb:BarCheckItem Content="Italic" Glyph="{dx:DXImage Image=Italic_16x16.png}" CategoryName="Format" 
                                  CheckedChanged="checkBtnItalic_CheckChanged"/>
            </dxb:ToolBarControl>
        </dxb:BarContainerControl>
    </Grid>
</Window>
xaml
<Application x:Class="WpfApplication3.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Window1.xaml" Startup="OnAppStartup_UpdateThemeName">
    <Application.Resources>

    </Application.Resources>
</Application>
vb
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes
Imports DevExpress.Xpf.Bars

Namespace WpfApplication3
    ''' <summary>
    ''' Interaction logic for Window1.xaml
    ''' </summary>
    Partial Public Class Window1
        Inherits Window

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub checkBtnItalic_CheckChanged(ByVal sender As Object, ByVal e As ItemClickEventArgs)
            '...
        End Sub

        Private Sub checkBtnBold_CheckChanged(ByVal sender As Object, ByVal e As DevExpress.Xpf.Bars.ItemClickEventArgs)
            '...
        End Sub
    End Class
End Namespace
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;
using DevExpress.Xpf.Bars;

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

        void checkBtnItalic_CheckChanged(object sender, ItemClickEventArgs e) {
            //...
        }

        void checkBtnBold_CheckChanged(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e) {
            //...
        }
    }
}

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

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-data-grid-implement-crud-operations/CS/CodeBehind/EFCore/LocalData/MainWindow.xaml#L15

xml
<dxb:BarButtonItem Content="Refresh (F5)" Command="{Binding View.Commands.RefreshDataSource, ElementName=grid}"
                   Glyph="{dx:DXImage SvgImages/Icon Builder/Actions_Refresh.svg}" BarItemDisplayMode="ContentAndGlyph" />
<dxb:BarButtonItem Content="Edit (F2)" Command="{Binding View.Commands.EditFocusedRow, ElementName=grid}"

wpf-docklayoutmanager-merge-ribbon-controls/CS/WpfApplication1/MainWindow.xaml#L13

xml
<dxb:BarButtonItem x:Name="biNew" Content="New" LargeGlyph="{dx:DXImage Image=New_32x32.png}"/>
<dxb:BarButtonItem x:Name="biOpen" Content="Open" Glyph="{dx:DXImage Image=Open_16x16.png}"/>
<dxb:BarButtonItem x:Name="biSave" Content="Save" Glyph="{dx:DXImage Image=Save_16x16.png}"/>

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

xml
<dxb:BarButtonItem Name="bAbout" Content="About"
               Glyph="{dxc:DXImage Image=Info_16x16.png}"
               LargeGlyph="{dxc:DXImage Image=Info_32x32.png}"

wpf-data-grid-extend-crud-operations/CS/AsyncCRUDOperations/MainWindow.xaml#L15

xml
<dxb:ToolBarControl>
    <dxb:BarButtonItem Content="Refresh (F5)" Command="{Binding View.Commands.RefreshDataSource, ElementName=grid}" Glyph="{dx:DXImage SvgImages/Icon Builder/Actions_Refresh.svg}" BarItemDisplayMode="ContentAndGlyph" />
    <dxb:BarButtonItem Content="Edit (F2)" Command="{Binding View.Commands.EditFocusedRow, ElementName=grid}" Glyph="{dx:DXImage SvgImages/Icon Builder/Actions_Edit.svg}" BarItemDisplayMode="ContentAndGlyph" />

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

xml
<dxr:RibbonPageGroup Caption="Database">
    <dxb:BarButtonItem x:Name="buttonAddRecord" Content="Add Record" LargeGlyph="{dx:DXImage Image=Add_32x32.png}" Glyph="{dx:DXImage Image=Add_16x16.png}" ItemClick="buttonAddRecord_ItemClick"/>
    <dxb:BarButtonItem x:Name="buttonRemoveRecord" Content="Remove Record" LargeGlyph="{dx:DXImage Image=Remove_32x32.png}" Glyph="{dx:DXImage Image=Remove_16x16.png}" ItemClick="buttonRemoveRecord_ItemClick"/>

See Also

CustomizationGlyph

BarItem.GlyphSize

LargeGlyph

Bar.GlyphSize

PopupMenu.GlyphSize

BarSubItem.SubItemsGlyphSize

BarLinkContainerItem.SubItemsGlyphSize

ToolbarGlyphSize

MenuGlyphSize

BarManager.AllowGlyphTheming

BarItem.AllowGlyphTheming

BarItem Class

BarItem Members

DevExpress.Xpf.Bars Namespace