Back to Devexpress

AccordionControl.CustomDrawHamburgerButton Event

windowsforms-devexpress-dot-xtrabars-dot-navigation-dot-accordioncontrol-0bd905da.md

latest4.1 KB
Original Source

AccordionControl.CustomDrawHamburgerButton Event

Fires before the hamburger button is displayed. Provides access to a drawing surface and allows you to draw the hamburger button.

Namespace : DevExpress.XtraBars.Navigation

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Events")]
public event CustomDrawHamburgerButtonEventHandler CustomDrawHamburgerButton
vb
<DXCategory("Events")>
Public Event CustomDrawHamburgerButton As CustomDrawHamburgerButtonEventHandler

Event Data

The CustomDrawHamburgerButton event's data class is CustomDrawHamburgerButtonEventArgs. The following properties provide information specific to this event:

PropertyDescription
BoundsGets the hamburger button bounds.
CacheProvides access to a drawing surface and a pen/brush/font cache.
HandledGets or sets whether the event is handled.
StateGets the hamburger button state: normal, hot tracked, pressed, disabled, or selected.

The event data class exposes the following methods:

MethodDescription
DefaultDraw()Draws the default hamburger button.

Example

The code below shows how to draw a custom image in the hamburger button.

csharp
private void accordionControl_CustomDrawHamburgerButton(object sender, CustomDrawHamburgerButtonEventArgs e) {
    // The State event argument returns whether the hamburger button is
    // enabled, disabled, hot tracked, etc.
    if (e.State == DevExpress.Utils.Drawing.ObjectState.Normal) {
        SvgImage image = svgImageCollection1[1];
        var palette = SvgPaletteHelper.GetSvgPalette(this.LookAndFeel, ObjectState.Normal);
        e.Cache.DrawImage(image.Render(e.Bounds.Size, palette), e.Bounds.Location);
        // The Handled event argument should be set to true
        // to prevent the default draw algorithm from being invoked.
        e.Handled = true;
    }
}
vb
Private Sub accordionControl1_CustomDrawHamburgerButton(ByVal sender As Object, ByVal e As DevExpress.XtraBars.Navigation.CustomDrawHamburgerButtonEventArgs) _
    Handles accordionControl1.CustomDrawHamburgerButton
    ' The State event argument returns whether the hamburger button is
    ' enabled, disabled, hot tracked, etc.
    If e.State = DevExpress.Utils.Drawing.ObjectState.Normal Then
        Dim image As SvgImage = svgImageCollection1(0)
        Dim palette = SvgPaletteHelper.GetSvgPalette(Me.LookAndFeel, ObjectState.Normal)
        e.Cache.DrawImage(image.Render(e.Bounds.Size, palette), e.Bounds.Location)
        ' The Handled event argument should be set to true
        ' to prevent the default draw algorithm from being invoked.
        e.Handled = True
    End If
End Sub

See Also

CustomDrawElement

ViewType

AccordionControl Class

AccordionControl Members

DevExpress.XtraBars.Navigation Namespace